


from collections import OrderedDict
from typing import Mapping

from packaging import version

from ...configuration_utils import PretrainedConfig
from ...onnx import OnnxConfig
from ...utils import logging


A__:   Any    =	logging.get_logger(__name__)

A__:   Any    =	{
    '''apple/mobilevitv2-1.0''': '''https://huggingface.co/apple/mobilevitv2-1.0/resolve/main/config.json''',
}







class A__	(						snake_case__				):
      __UpperCamelCase	:  str     	=							'mobilevitv2'






      def __init__(			self      :Optional[int]					,						SCREAMING_SNAKE_CASE      :List[Any]=3					,						SCREAMING_SNAKE_CASE      :Union[str, Any]=2_5_6					,						SCREAMING_SNAKE_CASE      :Dict=2					,						SCREAMING_SNAKE_CASE      :str=2.0					,						SCREAMING_SNAKE_CASE      :List[str]="swish"					,						SCREAMING_SNAKE_CASE      :Union[str, Any]=3					,						SCREAMING_SNAKE_CASE      :str=3_2					,						SCREAMING_SNAKE_CASE      :Dict=0.1					,						SCREAMING_SNAKE_CASE      :str=0.02					,						SCREAMING_SNAKE_CASE      :Optional[int]=1e-5					,						SCREAMING_SNAKE_CASE      :str=5_1_2					,						SCREAMING_SNAKE_CASE      :Any=[6, 1_2, 1_8]					,						SCREAMING_SNAKE_CASE      :str=0.1					,						SCREAMING_SNAKE_CASE      :Optional[Any]=2_5_5					,						SCREAMING_SNAKE_CASE      :Optional[Any]=[2, 4, 3]					,						SCREAMING_SNAKE_CASE      :str=[1_2_8, 1_9_2, 2_5_6]					,						SCREAMING_SNAKE_CASE      :Optional[int]=1.0					,						SCREAMING_SNAKE_CASE      :str=2					,						SCREAMING_SNAKE_CASE      :Any=0.0					,						SCREAMING_SNAKE_CASE      :Tuple=0.0					,						**SCREAMING_SNAKE_CASE      :Dict					,						)	-> Optional[Any]:




             '''simple docstring'''
             super().__init__(**SCREAMING_SNAKE_CASE     )

             _a   :			Dict					 =num_channels
             _a   :			Union[str, Any]					 =image_size
             _a   :			Any					 =patch_size
             _a   :			Any					 =expand_ratio
             _a   :			Dict					 =hidden_act
             _a   :			Optional[int]					 =conv_kernel_size
             _a   :			Any					 =output_stride
             _a   :			Dict					 =initializer_range
             _a   :			Optional[Any]					 =layer_norm_eps
             _a   :			Optional[Any]					 =n_attn_blocks
             _a   :			Union[str, Any]					 =base_attn_unit_dims
             _a   :			List[Any]					 =width_multiplier
             _a   :			Tuple					 =ffn_multiplier
             _a   :			Tuple					 =ffn_dropout
             _a   :			Union[str, Any]					 =attn_dropout
             _a   :			int					 =classifier_dropout_prob

             # decode head attributes for semantic segmentation
             _a   :			List[str]					 =aspp_out_channels
             _a   :			Optional[int]					 =atrous_rates
             _a   :			Optional[int]					 =aspp_dropout_prob
             _a   :			Union[str, Any]					 =semantic_loss_ignore_index







class A__	(						snake_case__				):
      __UpperCamelCase	:  Tuple     	=							version.parse("1.11"				)






      @property
      def __UpperCAmelCase	(			self      :Any     )	-> Mapping[str, Mapping[int, str]]:




             '''simple docstring'''
             return OrderedDict([("""pixel_values""", {0: """batch""", 1: """num_channels""", 2: """height""", 3: """width"""})]     )






      @property
      def __UpperCAmelCase	(			self      :int     )	-> Mapping[str, Mapping[int, str]]:




             '''simple docstring'''
             if self.task == "image-classification":
                    return OrderedDict([("""logits""", {0: """batch"""})]     )
             else:
                    return OrderedDict([("""last_hidden_state""", {0: """batch"""}), ("""pooler_output""", {0: """batch"""})]     )






      @property
      def __UpperCAmelCase	(			self      :Optional[Any]     )	-> float:




             '''simple docstring'''
             return 1e-4






'''simple docstring'''







from ...processing_utils import ProcessorMixin
from ...tokenization_utils_base import BatchEncoding







class A__	(						UpperCAmelCase__				):
      __UpperCamelCase	:  Optional[Any]     	=							["image_processor", "tokenizer"]
      __UpperCamelCase	:  Optional[Any]     	=							"EfficientNetImageProcessor"
      __UpperCamelCase	:  Union[str, Any]     	=							("BertTokenizer", "BertTokenizerFast")






      def __init__(			self      :Union[str, Any]					,						SCREAMING_SNAKE_CASE      :int					,						SCREAMING_SNAKE_CASE      :Optional[int]     )	-> List[str]:




             '''simple docstring'''
             super().__init__(SCREAMING_SNAKE_CASE					,						SCREAMING_SNAKE_CASE     )






      def __call__(			self      :str					,						SCREAMING_SNAKE_CASE      :List[Any]=None					,						SCREAMING_SNAKE_CASE      :Dict=None					,						SCREAMING_SNAKE_CASE      :Union[str, Any]="max_length"					,						SCREAMING_SNAKE_CASE      :Any=6_4					,						SCREAMING_SNAKE_CASE      :List[str]=None					,						**SCREAMING_SNAKE_CASE      :Union[str, Any]     )	-> Optional[int]:




             '''simple docstring'''
             if text is None and images is None:
                    raise ValueError("""You have to specify either text or images. Both cannot be none."""     )

             if text is not None:
                    _a   :			Dict					 =self.tokenizer(
                        SCREAMING_SNAKE_CASE					,						padding=SCREAMING_SNAKE_CASE					,						max_length=SCREAMING_SNAKE_CASE					,						return_tensors=SCREAMING_SNAKE_CASE					,						**SCREAMING_SNAKE_CASE     )

             if images is not None:
                    _a   :			Any					 =self.image_processor(SCREAMING_SNAKE_CASE					,						return_tensors=SCREAMING_SNAKE_CASE					,						**SCREAMING_SNAKE_CASE     )

             if text is not None and images is not None:
                    _a   :			Dict					 =image_features.pixel_values
                    return encoding
             elif text is not None:
                    return encoding
             else:
                    return BatchEncoding(data=dict(**SCREAMING_SNAKE_CASE     )					,						tensor_type=SCREAMING_SNAKE_CASE     )






      def __UpperCAmelCase	(			self      :Any					,						*SCREAMING_SNAKE_CASE      :Optional[int]					,						**SCREAMING_SNAKE_CASE      :str     )	-> Dict:




             '''simple docstring'''
             return self.tokenizer.batch_decode(*SCREAMING_SNAKE_CASE					,						**SCREAMING_SNAKE_CASE     )






      def __UpperCAmelCase	(			self      :int					,						*SCREAMING_SNAKE_CASE      :List[str]					,						**SCREAMING_SNAKE_CASE      :Union[str, Any]     )	-> Union[str, Any]:




             '''simple docstring'''
             return self.tokenizer.decode(*SCREAMING_SNAKE_CASE					,						**SCREAMING_SNAKE_CASE     )






      @property
      def __UpperCAmelCase	(			self      :Tuple     )	-> Tuple:




             '''simple docstring'''
             _a   :			int					 =self.tokenizer.model_input_names
             _a   :			Union[str, Any]					 =self.image_processor.model_input_names
             return list(dict.fromkeys(tokenizer_input_names + image_processor_input_names     )     )


