"""simple docstring"""






import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import AutoConfig
from ..clip.configuration_clip import CLIPVisionConfig


lowerCAmelCase__    :    str			=      logging.get_logger(__name__)
class 							snake_case			(					__UpperCAmelCase							):




					"""simple docstring"""

					snake_case__							       =					"vision-text-dual-encoder"
					snake_case__							       =					True







					def __init__(							self  :      Optional[int]       ,lowerCamelCase__  :      Optional[Any]=512       ,lowerCamelCase__  :      List[Any]=2.6_5_9_2       ,**lowerCamelCase__  :      Union[str, Any]     ):
									super().__init__(**lowerCamelCase__     )

									if "vision_config" not in kwargs:
													raise ValueError('`vision_config` can not be `None`.'     )

									if "text_config" not in kwargs:
													raise ValueError('`text_config` can not be `None`.'     )

									UpperCAmelCase__			 =				kwargs.pop('vision_config'     )
									UpperCAmelCase__			 =				kwargs.pop('text_config'     )

									UpperCAmelCase__			 =				vision_config.pop('model_type'     )
									UpperCAmelCase__			 =				text_config.pop('model_type'     )

									if vision_model_type == "clip":
													UpperCAmelCase__			 =				AutoConfig.for_model(lowerCamelCase__       ,**lowerCamelCase__     ).vision_config
									elif vision_model_type == "clip_vision_model":
													UpperCAmelCase__			 =				CLIPVisionConfig(**lowerCamelCase__     )
									else:
													UpperCAmelCase__			 =				AutoConfig.for_model(lowerCamelCase__       ,**lowerCamelCase__     )

									UpperCAmelCase__			 =				AutoConfig.for_model(lowerCamelCase__       ,**lowerCamelCase__     )

									UpperCAmelCase__			 =				projection_dim
									UpperCAmelCase__			 =				logit_scale_init_value







					@classmethod
					def 						__lowerCAmelCase		(							cls  :      int       ,lowerCamelCase__  :      PretrainedConfig       ,lowerCamelCase__  :      PretrainedConfig       ,**lowerCamelCase__  :      List[str]     ):
									return cls(vision_config=vision_config.to_dict()       ,text_config=text_config.to_dict()       ,**lowerCamelCase__     )







					def 						__lowerCAmelCase		(							self  :      Union[str, Any]     ):
									UpperCAmelCase__			 =				copy.deepcopy(self.__dict__     )
									UpperCAmelCase__			 =				self.vision_config.to_dict()
									UpperCAmelCase__			 =				self.text_config.to_dict()
									UpperCAmelCase__			 =				self.__class__.model_type
									return output




"""simple docstring"""






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__    :    List[Any]			=      logging.get_logger(__name__)

lowerCAmelCase__    :    Dict			=      {
    '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			(					__UpperCAmelCase							):




					"""simple docstring"""

					snake_case__							       =					"mobilevit"







					def __init__(							self  :      Union[str, Any]       ,lowerCamelCase__  :      Any=3       ,lowerCamelCase__  :      str=256       ,lowerCamelCase__  :      Optional[int]=2       ,lowerCamelCase__  :      Union[str, Any]=[144, 192, 240]       ,lowerCamelCase__  :      Optional[int]=[16, 32, 64, 96, 128, 160, 640]       ,lowerCamelCase__  :      Dict=4       ,lowerCamelCase__  :      int=2.0       ,lowerCamelCase__  :      Optional[Any]=4.0       ,lowerCamelCase__  :      Optional[int]="silu"       ,lowerCamelCase__  :      List[str]=3       ,lowerCamelCase__  :      int=32       ,lowerCamelCase__  :      int=0.1       ,lowerCamelCase__  :      List[str]=0.0       ,lowerCamelCase__  :      List[str]=0.1       ,lowerCamelCase__  :      Tuple=0.0_2       ,lowerCamelCase__  :      Union[str, Any]=1e-5       ,lowerCamelCase__  :      Tuple=True       ,lowerCamelCase__  :      Dict=256       ,lowerCamelCase__  :      Any=[6, 12, 18]       ,lowerCamelCase__  :      Optional[int]=0.1       ,lowerCamelCase__  :      List[str]=255       ,**lowerCamelCase__  :      List[Any]       ,):
									super().__init__(**lowerCamelCase__     )

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

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






class 							snake_case			(					__UpperCAmelCase							):




					"""simple docstring"""

					snake_case__							       =					version.parse("1.11"							)







					@property
					def 						__lowerCAmelCase		(							self  :      str     ):
									return OrderedDict([('pixel_values', {0: 'batch', 1: 'num_channels', 2: 'height', 3: 'width'})]     )







					@property
					def 						__lowerCAmelCase		(							self  :      Dict     ):
									if self.task == "image-classification":
													return OrderedDict([('logits', {0: 'batch'})]     )
									else:
													return OrderedDict([('last_hidden_state', {0: 'batch'}), ('pooler_output', {0: 'batch'})]     )







					@property
					def 						__lowerCAmelCase		(							self  :      str     ):
									return 1e-4



