





"""simple docstring"""




from ...configuration_utils import PretrainedConfig
from ...utils import logging


UpperCamelCase_									=logging.get_logger(__name__)

UpperCamelCase_									={
    """sayakpaul/vit-msn-base""": """https://huggingface.co/sayakpaul/vit-msn-base/resolve/main/config.json""",
    # See all ViT MSN models at https://huggingface.co/models?filter=vit_msn
}




class 			_a						(				_lowerCAmelCase    ):
				UpperCamelCase								=   '''vit_msn'''






				def __init__(			self		:   Union[str, Any],			lowerCAmelCase__		:   str=7_6_8,			lowerCAmelCase__		:   Dict=1_2,			lowerCAmelCase__		:   str=1_2,			lowerCAmelCase__		:   Optional[Any]=3_0_7_2,			lowerCAmelCase__		:   Tuple="gelu",			lowerCAmelCase__		:   List[str]=0.0,			lowerCAmelCase__		:   str=0.0,			lowerCAmelCase__		:   int=0.02,			lowerCAmelCase__		:   Dict=1e-0_6,			lowerCAmelCase__		:   Optional[int]=2_2_4,			lowerCAmelCase__		:   Union[str, Any]=1_6,			lowerCAmelCase__		:   Optional[Any]=3,			lowerCAmelCase__		:   int=True,			**lowerCAmelCase__		:   Any,			)     ->				Tuple:




										'''simple docstring'''



										super().__init__(**lowerCAmelCase__							)

										_UpperCamelCase      : Dict         =   hidden_size
										_UpperCamelCase      : str         =   num_hidden_layers
										_UpperCamelCase      : Dict         =   num_attention_heads
										_UpperCamelCase      : Any         =   intermediate_size
										_UpperCamelCase      : Optional[Any]         =   hidden_act
										_UpperCamelCase      : Union[str, Any]         =   hidden_dropout_prob
										_UpperCamelCase      : List[str]         =   attention_probs_dropout_prob
										_UpperCamelCase      : Optional[int]         =   initializer_range
										_UpperCamelCase      : str         =   layer_norm_eps
										_UpperCamelCase      : List[str]         =   image_size
										_UpperCamelCase      : Union[str, Any]         =   patch_size
										_UpperCamelCase      : Dict         =   num_channels
										_UpperCamelCase      : Dict         =   qkv_bias










"""simple docstring"""




from typing import List, Optional, Union

from ...image_utils import ImageInput
from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding, PaddingStrategy, PreTokenizedInput, TextInput, TruncationStrategy
from ...utils import TensorType




class 			_a						(				_lowerCAmelCase    ):
				UpperCamelCase								=   ['''image_processor''', '''tokenizer''']
				UpperCamelCase								=   '''BlipImageProcessor'''
				UpperCamelCase								=   '''AutoTokenizer'''






				def __init__(			self		:   List[str],			lowerCAmelCase__		:   Optional[int],			lowerCAmelCase__		:   Optional[int]							)     ->				int:




										'''simple docstring'''



										_UpperCamelCase      : Any         =   False
										super().__init__(lowerCAmelCase__,			lowerCAmelCase__							)
										_UpperCamelCase      : Tuple         =   self.image_processor






				def __call__(			self		:   str,			lowerCAmelCase__		:   ImageInput = None,			lowerCAmelCase__		:   Union[TextInput, PreTokenizedInput, List[TextInput], List[PreTokenizedInput]] = None,			lowerCAmelCase__		:   bool = True,			lowerCAmelCase__		:   Union[bool, str, PaddingStrategy] = False,			lowerCAmelCase__		:   Union[bool, str, TruncationStrategy] = None,			lowerCAmelCase__		:   Optional[int] = None,			lowerCAmelCase__		:   int = 0,			lowerCAmelCase__		:   Optional[int] = None,			lowerCAmelCase__		:   Optional[bool] = None,			lowerCAmelCase__		:   bool = False,			lowerCAmelCase__		:   bool = False,			lowerCAmelCase__		:   bool = False,			lowerCAmelCase__		:   bool = False,			lowerCAmelCase__		:   bool = False,			lowerCAmelCase__		:   bool = True,			lowerCAmelCase__		:   Optional[Union[str, TensorType]] = None,			**lowerCAmelCase__		:   Optional[Any],			)     ->				BatchEncoding:




										'''simple docstring'''



										if images is None and text is None:
																raise ValueError('''You have to specify either images or text.'''							)

										# Get only text
										if images is None:
																_UpperCamelCase      : int         =   self.tokenizer
																_UpperCamelCase      : List[str]         =   self.tokenizer(
																    text=lowerCAmelCase__,			add_special_tokens=lowerCAmelCase__,			padding=lowerCAmelCase__,			truncation=lowerCAmelCase__,			max_length=lowerCAmelCase__,			stride=lowerCAmelCase__,			pad_to_multiple_of=lowerCAmelCase__,			return_attention_mask=lowerCAmelCase__,			return_overflowing_tokens=lowerCAmelCase__,			return_special_tokens_mask=lowerCAmelCase__,			return_offsets_mapping=lowerCAmelCase__,			return_token_type_ids=lowerCAmelCase__,			return_length=lowerCAmelCase__,			verbose=lowerCAmelCase__,			return_tensors=lowerCAmelCase__,			**lowerCAmelCase__,			)
																return text_encoding

										# add pixel_values
										_UpperCamelCase      : List[str]         =   self.image_processor(lowerCAmelCase__,			return_tensors=lowerCAmelCase__							)

										if text is not None:
																_UpperCamelCase      : Any         =   self.tokenizer(
																    text=lowerCAmelCase__,			add_special_tokens=lowerCAmelCase__,			padding=lowerCAmelCase__,			truncation=lowerCAmelCase__,			max_length=lowerCAmelCase__,			stride=lowerCAmelCase__,			pad_to_multiple_of=lowerCAmelCase__,			return_attention_mask=lowerCAmelCase__,			return_overflowing_tokens=lowerCAmelCase__,			return_special_tokens_mask=lowerCAmelCase__,			return_offsets_mapping=lowerCAmelCase__,			return_token_type_ids=lowerCAmelCase__,			return_length=lowerCAmelCase__,			verbose=lowerCAmelCase__,			return_tensors=lowerCAmelCase__,			**lowerCAmelCase__,			)
										else:
																_UpperCamelCase      : List[Any]         =   None

										if text_encoding is not None:
																encoding_image_processor.update(lowerCAmelCase__							)

										return encoding_image_processor






				def     snake_case     (			self		:   List[Any],			*lowerCAmelCase__		:   List[str],			**lowerCAmelCase__		:   str							)     ->				Optional[int]:




										'''simple docstring'''



										return self.tokenizer.batch_decode(*lowerCAmelCase__,			**lowerCAmelCase__							)






				def     snake_case     (			self		:   List[Any],			*lowerCAmelCase__		:   Dict,			**lowerCAmelCase__		:   Any							)     ->				List[str]:




										'''simple docstring'''



										return self.tokenizer.decode(*lowerCAmelCase__,			**lowerCAmelCase__							)






				@property
				# Copied from transformers.models.blip.processing_blip.BlipProcessor.model_input_names
				def     snake_case     (			self		:   Any							)     ->				str:




										'''simple docstring'''



										_UpperCamelCase      : List[str]         =   self.tokenizer.model_input_names
										_UpperCamelCase      : Union[str, Any]         =   self.image_processor.model_input_names
										return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names							)							)



