





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


UpperCAmelCase_       : int							=    logging.get_logger(__name__)

UpperCAmelCase_       : List[Any]							=    {
    """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   lowercase__     (				__A	):
  __UpperCamelCase						  =	"""mobilevit"""







  def __init__(						self     ,    _lowercase=3     ,    _lowercase=256     ,    _lowercase=2     ,    _lowercase=[144, 192, 240]     ,    _lowercase=[16, 32, 64, 96, 128, 160, 640]     ,    _lowercase=4     ,    _lowercase=2.0     ,    _lowercase=4.0     ,    _lowercase="silu"     ,    _lowercase=3     ,    _lowercase=32     ,    _lowercase=0.1     ,    _lowercase=0.0     ,    _lowercase=0.1     ,    _lowercase=0.02     ,    _lowercase=1e-5     ,    _lowercase=True     ,    _lowercase=256     ,    _lowercase=[6, 12, 18]     ,    _lowercase=0.1     ,    _lowercase=255     ,    **_lowercase     ,    ):
       super().__init__(**_lowercase    )

       lowerCAmelCase_       :							Optional[Any]			 =		num_channels
       lowerCAmelCase_       :							Dict			 =		image_size
       lowerCAmelCase_       :							Optional[int]			 =		patch_size
       lowerCAmelCase_       :							Tuple			 =		hidden_sizes
       lowerCAmelCase_       :							Union[str, Any]			 =		neck_hidden_sizes
       lowerCAmelCase_       :							Any			 =		num_attention_heads
       lowerCAmelCase_       :							int			 =		mlp_ratio
       lowerCAmelCase_       :							Optional[Any]			 =		expand_ratio
       lowerCAmelCase_       :							Union[str, Any]			 =		hidden_act
       lowerCAmelCase_       :							str			 =		conv_kernel_size
       lowerCAmelCase_       :							Any			 =		output_stride
       lowerCAmelCase_       :							List[str]			 =		hidden_dropout_prob
       lowerCAmelCase_       :							Tuple			 =		attention_probs_dropout_prob
       lowerCAmelCase_       :							List[Any]			 =		classifier_dropout_prob
       lowerCAmelCase_       :							Optional[Any]			 =		initializer_range
       lowerCAmelCase_       :							str			 =		layer_norm_eps
       lowerCAmelCase_       :							List[Any]			 =		qkv_bias

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





class   lowercase__     (				__A	):
  __UpperCamelCase						  =	version.parse("""1.11"""	)







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







  @property
  def 						UpperCAmelCase__		(						self    ):
       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    ):
       return 1e-4







import copy

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


UpperCAmelCase_       : Union[str, Any]							=    logging.get_logger(__name__)





class   lowercase__     (				__A	):
  __UpperCamelCase						  =	"""vision-text-dual-encoder"""
  __UpperCamelCase						  =	True







  def __init__(						self     ,    _lowercase=512     ,    _lowercase=2.6592     ,    **_lowercase    ):
       super().__init__(**_lowercase    )

       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`."""    )

       lowerCAmelCase_       :							Dict			 =		kwargs.pop("""vision_config"""    )
       lowerCAmelCase_       :							Optional[int]			 =		kwargs.pop("""text_config"""    )

       lowerCAmelCase_       :							Tuple			 =		vision_config.pop("""model_type"""    )
       lowerCAmelCase_       :							str			 =		text_config.pop("""model_type"""    )

       if vision_model_type == "clip":
            lowerCAmelCase_       :							Dict			 =		AutoConfig.for_model(_lowercase     ,    **_lowercase    ).vision_config
       elif vision_model_type == "clip_vision_model":
            lowerCAmelCase_       :							Any			 =		CLIPVisionConfig(**_lowercase    )
       else:
            lowerCAmelCase_       :							Tuple			 =		AutoConfig.for_model(_lowercase     ,    **_lowercase    )

       lowerCAmelCase_       :							List[Any]			 =		AutoConfig.for_model(_lowercase     ,    **_lowercase    )

       lowerCAmelCase_       :							Union[str, Any]			 =		projection_dim
       lowerCAmelCase_       :							Optional[int]			 =		logit_scale_init_value







  @classmethod
  def 						UpperCAmelCase__		(						cls     ,    _lowercase     ,    _lowercase     ,    **_lowercase    ):
       return cls(vision_config=vision_config.to_dict()     ,    text_config=text_config.to_dict()     ,    **_lowercase    )







  def 						UpperCAmelCase__		(						self    ):
       lowerCAmelCase_       :							int			 =		copy.deepcopy(self.__dict__    )
       lowerCAmelCase_       :							List[str]			 =		self.vision_config.to_dict()
       lowerCAmelCase_       :							List[str]			 =		self.text_config.to_dict()
       lowerCAmelCase_       :							str			 =		self.__class__.model_type
       return output
