





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

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


class        __SCREAMING_SNAKE_CASE      (			UpperCamelCase_ ):
							_UpperCAmelCase				:  Dict			   =   """align_text_model"""







							def __init__(				self					:     str		, A					:     Union[str, Any]=3_0_5_2_2		, A					:     Union[str, Any]=7_6_8		, A					:     Any=1_2		, A					:     int=1_2		, A					:     Any=3_0_7_2		, A					:     Dict="gelu"		, A					:     Tuple=0.1		, A					:     str=0.1		, A					:     List[Any]=5_1_2		, A					:     Optional[Any]=2		, A					:     Dict=0.02		, A					:     List[str]=1e-12		, A					:     str=0		, A					:     List[Any]="absolute"		, A					:     Union[str, Any]=True		, **A					:     Optional[Any]		, )       ->Optional[int]:
										super().__init__(**_a      )

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







							@classmethod
							def 						__lowerCamelCase   (				cls					:     Union[str, Any]		, A					:     Any		, **A					:     Any      )       ->"PretrainedConfig":
										cls._set_token_in_kwargs(_a      )

										lowerCamelCase__       :						Tuple        =							cls.get_config_dict(_a		, **_a      )

										# get the text config dict if we are loading from AlignConfig
										if config_dict.get('''model_type'''      ) == "align":
													lowerCamelCase__       :						Any        =							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(_a		, **_a      )


class        __SCREAMING_SNAKE_CASE      (			UpperCamelCase_ ):
							_UpperCAmelCase				:  Union[str, Any]			   =   """align_vision_model"""







							def __init__(				self					:     List[str]		, A					:     Any = 3		, A					:     int = 6_0_0		, A					:     Optional[int] = 2.0		, A					:     Union[str, Any] = 3.1		, A					:     Tuple = 8		, A					:     str = [3, 3, 5, 3, 5, 5, 3]		, A					:     str = [3_2, 1_6, 2_4, 4_0, 8_0, 1_1_2, 1_9_2]		, A					:     str = [1_6, 2_4, 4_0, 8_0, 1_1_2, 1_9_2, 3_2_0]		, A					:     int = []		, A					:     List[str] = [1, 2, 2, 2, 1, 2, 1]		, A					:     List[str] = [1, 2, 2, 3, 3, 4, 1]		, A					:     Optional[int] = [1, 6, 6, 6, 6, 6, 6]		, A					:     Dict = 0.25		, A					:     Union[str, Any] = "swish"		, A					:     Any = 2_5_6_0		, A					:     Any = "mean"		, A					:     Union[str, Any] = 0.02		, A					:     Tuple = 0.0_01		, A					:     Union[str, Any] = 0.99		, A					:     List[Any] = 0.2		, **A					:     int		, )       ->List[str]:
										super().__init__(**_a      )

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







							@classmethod
							def 						__lowerCamelCase   (				cls					:     List[Any]		, A					:     Any		, **A					:     Optional[int]      )       ->"PretrainedConfig":
										cls._set_token_in_kwargs(_a      )

										lowerCamelCase__       :						Any        =							cls.get_config_dict(_a		, **_a      )

										# get the vision config dict if we are loading from AlignConfig
										if config_dict.get('''model_type'''      ) == "align":
													lowerCamelCase__       :						Optional[Any]        =							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(_a		, **_a      )


class        __SCREAMING_SNAKE_CASE      (			UpperCamelCase_ ):
							_UpperCAmelCase				:  str			   =   """align"""
							_UpperCAmelCase				:  Tuple			   =   True







							def __init__(				self					:     Union[str, Any]		, A					:     Union[str, Any]=None		, A					:     List[Any]=None		, A					:     Union[str, Any]=6_4_0		, A					:     List[str]=1.0		, A					:     Dict=0.02		, **A					:     Any		, )       ->Dict:
										super().__init__(**_a      )

										if text_config is None:
													lowerCamelCase__       :						List[str]        =							{}
													logger.info('''text_config is None. Initializing the AlignTextConfig with default values.'''      )

										if vision_config is None:
													lowerCamelCase__       :						List[Any]        =							{}
													logger.info('''vision_config is None. Initializing the AlignVisionConfig with default values.'''      )

										lowerCamelCase__       :						Optional[Any]        =							AlignTextConfig(**_a      )
										lowerCamelCase__       :						Optional[Any]        =							AlignVisionConfig(**_a      )

										lowerCamelCase__       :						List[Any]        =							projection_dim
										lowerCamelCase__       :						Optional[Any]        =							temperature_init_value
										lowerCamelCase__       :						int        =							initializer_range







							@classmethod
							def 						__lowerCamelCase   (				cls					:     List[Any]		, A					:     List[Any]		, A					:     str		, **A					:     Dict      )       ->Dict:
										return cls(text_config=text_config.to_dict()		, vision_config=vision_config.to_dict()		, **_a      )







							def 						__lowerCamelCase   (				self					:     Optional[Any]      )       ->List[str]:
										lowerCamelCase__       :						Dict        =							copy.deepcopy(self.__dict__      )
										lowerCamelCase__       :						Dict        =							self.text_config.to_dict()
										lowerCamelCase__       :						Dict        =							self.vision_config.to_dict()
										lowerCamelCase__       :						List[Any]        =							self.__class__.model_type
										return output










def 	_a						(   UpperCAmelCase					)    ->    int:







   """simple docstring"""

   if not isinstance(UpperCAmelCase      ,  UpperCAmelCase					):
      raise TypeError('''only integers accepted as input'''					)
   else:
      lowerCamelCase__       :						Any        =							str(abs(UpperCAmelCase					)					)
      lowerCamelCase__       :						Union[str, Any]        =							[list(UpperCAmelCase					) for char in range(len(UpperCAmelCase					)					)]
      for index in range(len(UpperCAmelCase					)					):
         num_transpositions[index].pop(UpperCAmelCase					)
      return max(
          int(''''''.join(list(UpperCAmelCase					)					)					) for transposition in num_transpositions					)


if __name__ == "__main__":
       __import__('doctest').testmod()



