

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


lowerCAmelCase_	     =     logging.get_logger(__name__)

lowerCAmelCase_	     =     {
    '''apple/mobilevit-small''': '''https://huggingface.co/apple/mobilevit-small/resolve/main/config.json''',
    '''apple/mobilevit-x-small''': '''https://huggingface.co/apple/mobilevit-x-small/resolve/main/config.json''',
    '''apple/mobilevit-xx-small''': '''https://huggingface.co/apple/mobilevit-xx-small/resolve/main/config.json''',
    '''apple/deeplabv3-mobilevit-small''': (
        '''https://huggingface.co/apple/deeplabv3-mobilevit-small/resolve/main/config.json'''
    ),
    '''apple/deeplabv3-mobilevit-x-small''': (
        '''https://huggingface.co/apple/deeplabv3-mobilevit-x-small/resolve/main/config.json'''
    ),
    '''apple/deeplabv3-mobilevit-xx-small''': (
        '''https://huggingface.co/apple/deeplabv3-mobilevit-xx-small/resolve/main/config.json'''
    ),
    # See all MobileViT models at https://huggingface.co/models?filter=mobilevit
}





class      snake_case_       (		__A ):







			'''simple docstring'''

			SCREAMING_SNAKE_CASE					:       Optional[int]						      =    "mobilevit"







			def __init__(					self			:    List[str]							,       _UpperCamelCase			:    List[str]=3							,       _UpperCamelCase			:    Optional[Any]=2_5_6							,       _UpperCamelCase			:    Union[str, Any]=2							,       _UpperCamelCase			:    str=[1_4_4, 1_9_2, 2_4_0]							,       _UpperCamelCase			:    Optional[int]=[1_6, 3_2, 6_4, 9_6, 1_2_8, 1_6_0, 6_4_0]							,       _UpperCamelCase			:    Optional[Any]=4							,       _UpperCamelCase			:    Optional[Any]=2.0							,       _UpperCamelCase			:    str=4.0							,       _UpperCamelCase			:    Any="silu"							,       _UpperCamelCase			:    str=3							,       _UpperCamelCase			:    Tuple=3_2							,       _UpperCamelCase			:    Tuple=0.1							,       _UpperCamelCase			:    Optional[int]=0.0							,       _UpperCamelCase			:    Any=0.1							,       _UpperCamelCase			:    Optional[Any]=0.02							,       _UpperCamelCase			:    List[str]=1e-5							,       _UpperCamelCase			:    Tuple=True							,       _UpperCamelCase			:    str=2_5_6							,       _UpperCamelCase			:    Optional[int]=[6, 1_2, 1_8]							,       _UpperCamelCase			:    Optional[int]=0.1							,       _UpperCamelCase			:    Dict=2_5_5							,       **_UpperCamelCase			:    Tuple							,       )				->List[Any]:
									super().__init__(**_UpperCamelCase							)

									snake_case_       =     num_channels
									snake_case_       =     image_size
									snake_case_       =     patch_size
									snake_case_       =     hidden_sizes
									snake_case_       =     neck_hidden_sizes
									snake_case_       =     num_attention_heads
									snake_case_       =     mlp_ratio
									snake_case_       =     expand_ratio
									snake_case_       =     hidden_act
									snake_case_       =     conv_kernel_size
									snake_case_       =     output_stride
									snake_case_       =     hidden_dropout_prob
									snake_case_       =     attention_probs_dropout_prob
									snake_case_       =     classifier_dropout_prob
									snake_case_       =     initializer_range
									snake_case_       =     layer_norm_eps
									snake_case_       =     qkv_bias

									# decode head attributes for semantic segmentation
									snake_case_       =     aspp_out_channels
									snake_case_       =     atrous_rates
									snake_case_       =     aspp_dropout_prob
									snake_case_       =     semantic_loss_ignore_index






class      snake_case_       (		__A ):







			'''simple docstring'''

			SCREAMING_SNAKE_CASE					:       List[Any]						      =    version.parse("1.11" )







			@property
			def     snake_case__(					self			:    List[Any]							)				->Mapping[str, Mapping[int, str]]:
									return OrderedDict([('''pixel_values''', {0: '''batch''', 1: '''num_channels''', 2: '''height''', 3: '''width'''})]							)







			@property
			def     snake_case__(					self			:    Optional[int]							)				->Mapping[str, Mapping[int, str]]:
									if self.task == "image-classification":
															return OrderedDict([('''logits''', {0: '''batch'''})]							)
									else:
															return OrderedDict([('''last_hidden_state''', {0: '''batch'''}), ('''pooler_output''', {0: '''batch'''})]							)







			@property
			def     snake_case__(					self			:    Any							)				->float:
									return 1e-4


import warnings
from contextlib import contextmanager

from ...processing_utils import ProcessorMixin





class      snake_case_       (		__A ):







			'''simple docstring'''

			SCREAMING_SNAKE_CASE					:       List[str]						      =    ["image_processor", "tokenizer"]
			SCREAMING_SNAKE_CASE					:       List[Any]						      =    "AutoImageProcessor"
			SCREAMING_SNAKE_CASE					:       Optional[int]						      =    "AutoTokenizer"







			def __init__(					self			:    List[str]							,       _UpperCamelCase			:    List[str]=None							,       _UpperCamelCase			:    Any=None							,       **_UpperCamelCase			:    Tuple							)				->str:
									snake_case_       =     None
									if "feature_extractor" in kwargs:
															warnings.warn(
															    '''The `feature_extractor` argument is deprecated and will be removed in v5, use `image_processor`'''
															    ''' instead.'''							,       _UpperCamelCase							,       )
															snake_case_       =     kwargs.pop('''feature_extractor'''							)

									snake_case_       =     image_processor if image_processor is not None else feature_extractor
									if image_processor is None:
															raise ValueError('''You need to specify an `image_processor`.'''							)
									if tokenizer is None:
															raise ValueError('''You need to specify a `tokenizer`.'''							)

									super().__init__(_UpperCamelCase							,       _UpperCamelCase							)
									snake_case_       =     self.image_processor
									snake_case_       =     False







			def __call__(					self			:    int							,       *_UpperCamelCase			:    Tuple							,       **_UpperCamelCase			:    Any							)				->Tuple:
									# For backward compatibility
									if self._in_target_context_manager:
															return self.current_processor(*_UpperCamelCase							,       **_UpperCamelCase							)

									snake_case_       =     kwargs.pop('''images'''							,       _UpperCamelCase							)
									snake_case_       =     kwargs.pop('''text'''							,       _UpperCamelCase							)
									if len(_UpperCamelCase							) > 0:
															snake_case_       =     args[0]
															snake_case_       =     args[1:]

									if images is None and text is None:
															raise ValueError('''You need to specify either an `images` or `text` input to process.'''							)

									if images is not None:
															snake_case_       =     self.image_processor(_UpperCamelCase							,       *_UpperCamelCase							,       **_UpperCamelCase							)
									if text is not None:
															snake_case_       =     self.tokenizer(_UpperCamelCase							,       **_UpperCamelCase							)

									if text is None:
															return inputs
									elif images is None:
															return encodings
									else:
															snake_case_       =     encodings['''input_ids''']
															return inputs







			def     snake_case__(					self			:    List[Any]							,       *_UpperCamelCase			:    Union[str, Any]							,       **_UpperCamelCase			:    Tuple							)				->Any:
									return self.tokenizer.batch_decode(*_UpperCamelCase							,       **_UpperCamelCase							)







			def     snake_case__(					self			:    Optional[Any]							,       *_UpperCamelCase			:    List[Any]							,       **_UpperCamelCase			:    Union[str, Any]							)				->List[str]:
									return self.tokenizer.decode(*_UpperCamelCase							,       **_UpperCamelCase							)







			@contextmanager
			def     snake_case__(					self			:    Any							)				->Any:
									warnings.warn(
									    '''`as_target_processor` is deprecated and will be removed in v5 of Transformers. You can process your '''
									    '''labels by using the argument `text` of the regular `__call__` method (either in the same call as '''
									    '''your images inputs, or in a separate call.'''							)
									snake_case_       =     True
									snake_case_       =     self.tokenizer
									yield
									snake_case_       =     self.image_processor
									snake_case_       =     False







			@property
			def     snake_case__(					self			:    Optional[int]							)				->int:
									warnings.warn(
									    '''`feature_extractor_class` is deprecated and will be removed in v5. Use `image_processor_class` instead.'''							,       _UpperCamelCase							,       )
									return self.image_processor_class







			@property
			def     snake_case__(					self			:    Union[str, Any]							)				->List[Any]:
									warnings.warn(
									    '''`feature_extractor` is deprecated and will be removed in v5. Use `image_processor` instead.'''							,       _UpperCamelCase							,       )
									return self.image_processor