






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


if TYPE_CHECKING:
			pass

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


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

_UpperCAmelCase			:		Optional[Any]   				=    {
    """kakaobrain/align-base""": """https://huggingface.co/kakaobrain/align-base/resolve/main/config.json""",
}
class  lowerCAmelCase_       (				_snake_case					):
							UpperCamelCase_		:Optional[Any]		      =    """align_text_model"""




							def __init__(   self     :   Any ,							SCREAMING_SNAKE_CASE_     :   Union[str, Any]=30_522 ,							SCREAMING_SNAKE_CASE_     :   Optional[Any]=768 ,							SCREAMING_SNAKE_CASE_     :   Any=12 ,							SCREAMING_SNAKE_CASE_     :   Optional[Any]=12 ,							SCREAMING_SNAKE_CASE_     :   Dict=3_072 ,							SCREAMING_SNAKE_CASE_     :   Optional[int]="gelu" ,							SCREAMING_SNAKE_CASE_     :   Dict=0.1 ,							SCREAMING_SNAKE_CASE_     :   Optional[Any]=0.1 ,							SCREAMING_SNAKE_CASE_     :   Tuple=512 ,							SCREAMING_SNAKE_CASE_     :   str=2 ,							SCREAMING_SNAKE_CASE_     :   Optional[int]=0.02 ,							SCREAMING_SNAKE_CASE_     :   Union[str, Any]=1e-12 ,							SCREAMING_SNAKE_CASE_     :   Dict=0 ,							SCREAMING_SNAKE_CASE_     :   int="absolute" ,							SCREAMING_SNAKE_CASE_     :   int=True ,							**SCREAMING_SNAKE_CASE_     :   Optional[Any] ,							):
											super().__init__(**snake_case_	)

											lowerCAmelCase__      			=						vocab_size
											lowerCAmelCase__      			=						hidden_size
											lowerCAmelCase__      			=						num_hidden_layers
											lowerCAmelCase__      			=						num_attention_heads
											lowerCAmelCase__      			=						hidden_act
											lowerCAmelCase__      			=						intermediate_size
											lowerCAmelCase__      			=						hidden_dropout_prob
											lowerCAmelCase__      			=						attention_probs_dropout_prob
											lowerCAmelCase__      			=						max_position_embeddings
											lowerCAmelCase__      			=						type_vocab_size
											lowerCAmelCase__      			=						initializer_range
											lowerCAmelCase__      			=						layer_norm_eps
											lowerCAmelCase__      			=						position_embedding_type
											lowerCAmelCase__      			=						use_cache
											lowerCAmelCase__      			=						pad_token_id




							@classmethod
							def 						__snake_case					(   cls     :   int ,							SCREAMING_SNAKE_CASE_     :   int ,							**SCREAMING_SNAKE_CASE_     :   int	):
											cls._set_token_in_kwargs(snake_case_	)

											lowerCAmelCase__      			=						cls.get_config_dict(snake_case_ ,							**snake_case_	)

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



class  lowerCAmelCase_       (				_snake_case					):
							UpperCamelCase_		:Optional[Any]		      =    """align_vision_model"""




							def __init__(   self     :   str ,							SCREAMING_SNAKE_CASE_     :   Tuple = 3 ,							SCREAMING_SNAKE_CASE_     :   Optional[int] = 600 ,							SCREAMING_SNAKE_CASE_     :   List[str] = 2.0 ,							SCREAMING_SNAKE_CASE_     :   Optional[Any] = 3.1 ,							SCREAMING_SNAKE_CASE_     :   List[Any] = 8 ,							SCREAMING_SNAKE_CASE_     :   Dict = [3, 3, 5, 3, 5, 5, 3] ,							SCREAMING_SNAKE_CASE_     :   List[Any] = [32, 16, 24, 40, 80, 112, 192] ,							SCREAMING_SNAKE_CASE_     :   Optional[Any] = [16, 24, 40, 80, 112, 192, 320] ,							SCREAMING_SNAKE_CASE_     :   Tuple = [] ,							SCREAMING_SNAKE_CASE_     :   Dict = [1, 2, 2, 2, 1, 2, 1] ,							SCREAMING_SNAKE_CASE_     :   List[Any] = [1, 2, 2, 3, 3, 4, 1] ,							SCREAMING_SNAKE_CASE_     :   str = [1, 6, 6, 6, 6, 6, 6] ,							SCREAMING_SNAKE_CASE_     :   Tuple = 0.25 ,							SCREAMING_SNAKE_CASE_     :   Optional[Any] = "swish" ,							SCREAMING_SNAKE_CASE_     :   Any = 2_560 ,							SCREAMING_SNAKE_CASE_     :   Optional[int] = "mean" ,							SCREAMING_SNAKE_CASE_     :   Any = 0.02 ,							SCREAMING_SNAKE_CASE_     :   Dict = 0.001 ,							SCREAMING_SNAKE_CASE_     :   Any = 0.99 ,							SCREAMING_SNAKE_CASE_     :   Optional[int] = 0.2 ,							**SCREAMING_SNAKE_CASE_     :   str ,							):
											super().__init__(**snake_case_	)

											lowerCAmelCase__      			=						num_channels
											lowerCAmelCase__      			=						image_size
											lowerCAmelCase__      			=						width_coefficient
											lowerCAmelCase__      			=						depth_coefficient
											lowerCAmelCase__      			=						depth_divisor
											lowerCAmelCase__      			=						kernel_sizes
											lowerCAmelCase__      			=						in_channels
											lowerCAmelCase__      			=						out_channels
											lowerCAmelCase__      			=						depthwise_padding
											lowerCAmelCase__      			=						strides
											lowerCAmelCase__      			=						num_block_repeats
											lowerCAmelCase__      			=						expand_ratios
											lowerCAmelCase__      			=						squeeze_expansion_ratio
											lowerCAmelCase__      			=						hidden_act
											lowerCAmelCase__      			=						hidden_dim
											lowerCAmelCase__      			=						pooling_type
											lowerCAmelCase__      			=						initializer_range
											lowerCAmelCase__      			=						batch_norm_eps
											lowerCAmelCase__      			=						batch_norm_momentum
											lowerCAmelCase__      			=						drop_connect_rate
											lowerCAmelCase__      			=						sum(snake_case_	) * 4




							@classmethod
							def 						__snake_case					(   cls     :   List[str] ,							SCREAMING_SNAKE_CASE_     :   Dict ,							**SCREAMING_SNAKE_CASE_     :   int	):
											cls._set_token_in_kwargs(snake_case_	)

											lowerCAmelCase__      			=						cls.get_config_dict(snake_case_ ,							**snake_case_	)

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



class  lowerCAmelCase_       (				_snake_case					):
							UpperCamelCase_		:Tuple		      =    """align"""
							UpperCamelCase_		:Dict		      =    True




							def __init__(   self     :   Optional[Any] ,							SCREAMING_SNAKE_CASE_     :   int=None ,							SCREAMING_SNAKE_CASE_     :   Any=None ,							SCREAMING_SNAKE_CASE_     :   List[str]=640 ,							SCREAMING_SNAKE_CASE_     :   List[Any]=1.0 ,							SCREAMING_SNAKE_CASE_     :   List[Any]=0.02 ,							**SCREAMING_SNAKE_CASE_     :   Optional[int] ,							):
											super().__init__(**snake_case_	)

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

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

											lowerCAmelCase__      			=						AlignTextConfig(**snake_case_	)
											lowerCAmelCase__      			=						AlignVisionConfig(**snake_case_	)

											lowerCAmelCase__      			=						projection_dim
											lowerCAmelCase__      			=						temperature_init_value
											lowerCAmelCase__      			=						initializer_range




							@classmethod
							def 						__snake_case					(   cls     :   Optional[Any] ,							SCREAMING_SNAKE_CASE_     :   List[str] ,							SCREAMING_SNAKE_CASE_     :   Optional[int] ,							**SCREAMING_SNAKE_CASE_     :   Union[str, Any]	):
											return cls(text_config=text_config.to_dict() ,							vision_config=vision_config.to_dict() ,							**snake_case_	)




							def 						__snake_case					(   self     :   Tuple	):
											lowerCAmelCase__      			=						copy.deepcopy(self.__dict__	)
											lowerCAmelCase__      			=						self.text_config.to_dict()
											lowerCAmelCase__      			=						self.vision_config.to_dict()
											lowerCAmelCase__      			=						self.__class__.model_type
											return output













from ...configuration_utils import PretrainedConfig
class  lowerCAmelCase_       (				snake_case__					):
							UpperCamelCase_		:List[str]		      =    'bert-generation'




							def __init__(   self     :   Tuple ,							SCREAMING_SNAKE_CASE_     :   List[str]=50_358 ,							SCREAMING_SNAKE_CASE_     :   List[Any]=1_024 ,							SCREAMING_SNAKE_CASE_     :   Optional[Any]=24 ,							SCREAMING_SNAKE_CASE_     :   Any=16 ,							SCREAMING_SNAKE_CASE_     :   Tuple=4_096 ,							SCREAMING_SNAKE_CASE_     :   str="gelu" ,							SCREAMING_SNAKE_CASE_     :   List[str]=0.1 ,							SCREAMING_SNAKE_CASE_     :   Tuple=0.1 ,							SCREAMING_SNAKE_CASE_     :   List[Any]=512 ,							SCREAMING_SNAKE_CASE_     :   List[Any]=0.02 ,							SCREAMING_SNAKE_CASE_     :   Union[str, Any]=1e-12 ,							SCREAMING_SNAKE_CASE_     :   List[Any]=0 ,							SCREAMING_SNAKE_CASE_     :   Union[str, Any]=2 ,							SCREAMING_SNAKE_CASE_     :   int=1 ,							SCREAMING_SNAKE_CASE_     :   str="absolute" ,							SCREAMING_SNAKE_CASE_     :   Tuple=True ,							**SCREAMING_SNAKE_CASE_     :   str ,							):
											super().__init__(pad_token_id=SCREAMING_SNAKE_CASE_ ,							bos_token_id=SCREAMING_SNAKE_CASE_ ,							eos_token_id=SCREAMING_SNAKE_CASE_ ,							**SCREAMING_SNAKE_CASE_	)

											lowerCAmelCase__      			=						vocab_size
											lowerCAmelCase__      			=						hidden_size
											lowerCAmelCase__      			=						num_hidden_layers
											lowerCAmelCase__      			=						num_attention_heads
											lowerCAmelCase__      			=						hidden_act
											lowerCAmelCase__      			=						intermediate_size
											lowerCAmelCase__      			=						hidden_dropout_prob
											lowerCAmelCase__      			=						attention_probs_dropout_prob
											lowerCAmelCase__      			=						max_position_embeddings
											lowerCAmelCase__      			=						initializer_range
											lowerCAmelCase__      			=						layer_norm_eps
											lowerCAmelCase__      			=						position_embedding_type
											lowerCAmelCase__      			=						use_cache





