






import copy
import os
from typing import TYPE_CHECKING, List, Union


if TYPE_CHECKING:
  pass

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


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

_a    :   Optional[int]        =			{
    """kakaobrain/align-base""": """https://huggingface.co/kakaobrain/align-base/resolve/main/config.json""",
}







class 	_UpperCAmelCase  (  _A		):




      """simple docstring"""



      A          =    '''align_text_model'''
      def __init__(   self    ,	_lowerCAmelCase=30_522    ,	_lowerCAmelCase=768    ,	_lowerCAmelCase=12    ,	_lowerCAmelCase=12    ,	_lowerCAmelCase=3_072    ,	_lowerCAmelCase="gelu"    ,	_lowerCAmelCase=0.1    ,	_lowerCAmelCase=0.1    ,	_lowerCAmelCase=512    ,	_lowerCAmelCase=2    ,	_lowerCAmelCase=0.02    ,	_lowerCAmelCase=1e-12    ,	_lowerCAmelCase=0    ,	_lowerCAmelCase="absolute"    ,	_lowerCAmelCase=True    ,	**_lowerCAmelCase    ,	):



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

          lowerCAmelCase__   :Any      							=				vocab_size
          lowerCAmelCase__   :Any      							=				hidden_size
          lowerCAmelCase__   :int      							=				num_hidden_layers
          lowerCAmelCase__   :Optional[int]      							=				num_attention_heads
          lowerCAmelCase__   :Tuple      							=				hidden_act
          lowerCAmelCase__   :int      							=				intermediate_size
          lowerCAmelCase__   :Union[str, Any]      							=				hidden_dropout_prob
          lowerCAmelCase__   :Any      							=				attention_probs_dropout_prob
          lowerCAmelCase__   :Optional[Any]      							=				max_position_embeddings
          lowerCAmelCase__   :Dict      							=				type_vocab_size
          lowerCAmelCase__   :Any      							=				initializer_range
          lowerCAmelCase__   :Optional[Any]      							=				layer_norm_eps
          lowerCAmelCase__   :List[str]      							=				position_embedding_type
          lowerCAmelCase__   :str      							=				use_cache
          lowerCAmelCase__   :Optional[int]      							=				pad_token_id



      @classmethod
      def 			snake_case_      (   cls    ,	_lowerCAmelCase    ,	**_lowerCAmelCase		):



          '''simple docstring'''
          cls._set_token_in_kwargs(_lowerCAmelCase		)

          lowerCAmelCase__   :Union[str, Any]      							=				cls.get_config_dict(_lowerCAmelCase    ,	**_lowerCAmelCase		)

          # get the text config dict if we are loading from AlignConfig
          if config_dict.get("model_type"		) == "align":
              lowerCAmelCase__   :List[str]      							=				config_dict["text_config"]

          if "model_type" in config_dict and hasattr(cls    ,	"model_type"		) and config_dict["model_type"] != cls.model_type:
              logger.warning(
                  f'''You are using a model of type {config_dict["model_type"]} to instantiate a model of type '''
                  f'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.'''		)

          return cls.from_dict(_lowerCAmelCase    ,	**_lowerCAmelCase		)







class 	_UpperCAmelCase  (  _A		):




      """simple docstring"""



      A          =    '''align_vision_model'''
      def __init__(   self    ,	_lowerCAmelCase = 3    ,	_lowerCAmelCase = 600    ,	_lowerCAmelCase = 2.0    ,	_lowerCAmelCase = 3.1    ,	_lowerCAmelCase = 8    ,	_lowerCAmelCase = [3, 3, 5, 3, 5, 5, 3]    ,	_lowerCAmelCase = [32, 16, 24, 40, 80, 112, 192]    ,	_lowerCAmelCase = [16, 24, 40, 80, 112, 192, 320]    ,	_lowerCAmelCase = []    ,	_lowerCAmelCase = [1, 2, 2, 2, 1, 2, 1]    ,	_lowerCAmelCase = [1, 2, 2, 3, 3, 4, 1]    ,	_lowerCAmelCase = [1, 6, 6, 6, 6, 6, 6]    ,	_lowerCAmelCase = 0.25    ,	_lowerCAmelCase = "swish"    ,	_lowerCAmelCase = 2_560    ,	_lowerCAmelCase = "mean"    ,	_lowerCAmelCase = 0.02    ,	_lowerCAmelCase = 0.001    ,	_lowerCAmelCase = 0.99    ,	_lowerCAmelCase = 0.2    ,	**_lowerCAmelCase    ,	):



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

          lowerCAmelCase__   :Union[str, Any]      							=				num_channels
          lowerCAmelCase__   :List[Any]      							=				image_size
          lowerCAmelCase__   :Tuple      							=				width_coefficient
          lowerCAmelCase__   :Optional[int]      							=				depth_coefficient
          lowerCAmelCase__   :str      							=				depth_divisor
          lowerCAmelCase__   :int      							=				kernel_sizes
          lowerCAmelCase__   :Any      							=				in_channels
          lowerCAmelCase__   :int      							=				out_channels
          lowerCAmelCase__   :Optional[int]      							=				depthwise_padding
          lowerCAmelCase__   :Dict      							=				strides
          lowerCAmelCase__   :List[Any]      							=				num_block_repeats
          lowerCAmelCase__   :List[Any]      							=				expand_ratios
          lowerCAmelCase__   :Any      							=				squeeze_expansion_ratio
          lowerCAmelCase__   :Tuple      							=				hidden_act
          lowerCAmelCase__   :int      							=				hidden_dim
          lowerCAmelCase__   :Any      							=				pooling_type
          lowerCAmelCase__   :str      							=				initializer_range
          lowerCAmelCase__   :List[Any]      							=				batch_norm_eps
          lowerCAmelCase__   :str      							=				batch_norm_momentum
          lowerCAmelCase__   :Optional[Any]      							=				drop_connect_rate
          lowerCAmelCase__   :str      							=				sum(_lowerCAmelCase		) * 4



      @classmethod
      def 			snake_case_      (   cls    ,	_lowerCAmelCase    ,	**_lowerCAmelCase		):



          '''simple docstring'''
          cls._set_token_in_kwargs(_lowerCAmelCase		)

          lowerCAmelCase__   :List[Any]      							=				cls.get_config_dict(_lowerCAmelCase    ,	**_lowerCAmelCase		)

          # get the vision config dict if we are loading from AlignConfig
          if config_dict.get("model_type"		) == "align":
              lowerCAmelCase__   :Optional[int]      							=				config_dict["vision_config"]

          if "model_type" in config_dict and hasattr(cls    ,	"model_type"		) and config_dict["model_type"] != cls.model_type:
              logger.warning(
                  f'''You are using a model of type {config_dict["model_type"]} to instantiate a model of type '''
                  f'''{cls.model_type}. This is not supported for all configurations of models and can yield errors.'''		)

          return cls.from_dict(_lowerCAmelCase    ,	**_lowerCAmelCase		)







class 	_UpperCAmelCase  (  _A		):




      """simple docstring"""



      A          =    '''align'''
      A          =    True
      def __init__(   self    ,	_lowerCAmelCase=None    ,	_lowerCAmelCase=None    ,	_lowerCAmelCase=640    ,	_lowerCAmelCase=1.0    ,	_lowerCAmelCase=0.02    ,	**_lowerCAmelCase    ,	):



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

          if text_config is None:
              lowerCAmelCase__   :int      							=				{}
              logger.info("text_config is None. Initializing the AlignTextConfig with default values."		)

          if vision_config is None:
              lowerCAmelCase__   :Tuple      							=				{}
              logger.info("vision_config is None. Initializing the AlignVisionConfig with default values."		)

          lowerCAmelCase__   :Optional[int]      							=				AlignTextConfig(**_lowerCAmelCase		)
          lowerCAmelCase__   :Union[str, Any]      							=				AlignVisionConfig(**_lowerCAmelCase		)

          lowerCAmelCase__   :Any      							=				projection_dim
          lowerCAmelCase__   :Tuple      							=				temperature_init_value
          lowerCAmelCase__   :Any      							=				initializer_range
      @classmethod
      def 			snake_case_      (   cls    ,	_lowerCAmelCase    ,	_lowerCAmelCase    ,	**_lowerCAmelCase		):



          '''simple docstring'''
          return cls(text_config=text_config.to_dict()    ,	vision_config=vision_config.to_dict()    ,	**_lowerCAmelCase		)



      def 			snake_case_      (   self		):



          '''simple docstring'''
          lowerCAmelCase__   :List[str]      							=				copy.deepcopy(self.__dict__		)
          lowerCAmelCase__   :Tuple      							=				self.text_config.to_dict()
          lowerCAmelCase__   :Tuple      							=				self.vision_config.to_dict()
          lowerCAmelCase__   :int      							=				self.__class__.model_type
          return output











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    :   Tuple        =			logging.get_logger(__name__)

_a    :   Optional[int]        =			{
    """facebook/levit-128S""": """https://huggingface.co/facebook/levit-128S/resolve/main/config.json""",
    # See all LeViT models at https://huggingface.co/models?filter=levit
}







class 	_UpperCAmelCase  (  _A		):




      """simple docstring"""



      A          =    '''levit'''
      def __init__(   self    ,	_lowerCAmelCase=224    ,	_lowerCAmelCase=3    ,	_lowerCAmelCase=3    ,	_lowerCAmelCase=2    ,	_lowerCAmelCase=1    ,	_lowerCAmelCase=16    ,	_lowerCAmelCase=[128, 256, 384]    ,	_lowerCAmelCase=[4, 8, 12]    ,	_lowerCAmelCase=[4, 4, 4]    ,	_lowerCAmelCase=[16, 16, 16]    ,	_lowerCAmelCase=0    ,	_lowerCAmelCase=[2, 2, 2]    ,	_lowerCAmelCase=[2, 2, 2]    ,	_lowerCAmelCase=0.02    ,	**_lowerCAmelCase    ,	):



          '''simple docstring'''
          super().__init__(**_lowerCAmelCase		)
          lowerCAmelCase__   :List[str]      							=				image_size
          lowerCAmelCase__   :Dict      							=				num_channels
          lowerCAmelCase__   :List[Any]      							=				kernel_size
          lowerCAmelCase__   :List[Any]      							=				stride
          lowerCAmelCase__   :Tuple      							=				padding
          lowerCAmelCase__   :str      							=				hidden_sizes
          lowerCAmelCase__   :Union[str, Any]      							=				num_attention_heads
          lowerCAmelCase__   :Optional[int]      							=				depths
          lowerCAmelCase__   :Union[str, Any]      							=				key_dim
          lowerCAmelCase__   :str      							=				drop_path_rate
          lowerCAmelCase__   :int      							=				patch_size
          lowerCAmelCase__   :Dict      							=				attention_ratio
          lowerCAmelCase__   :Dict      							=				mlp_ratio
          lowerCAmelCase__   :Optional[int]      							=				initializer_range
          lowerCAmelCase__   :Tuple      							=				[
              ["Subsample", key_dim[0], hidden_sizes[0] // key_dim[0], 4, 2, 2],
              ["Subsample", key_dim[0], hidden_sizes[1] // key_dim[0], 4, 2, 2],
          ]







class 	_UpperCAmelCase  (  _A		):




      """simple docstring"""



      A          =    version.parse('''1.11'''		)
      @property
      def 			snake_case_      (   self		):



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



      @property
      def 			snake_case_      (   self		):



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



