





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   _UpperCamelCase  (       _snake_case  ):







					'''simple docstring'''

					lowerCamelCase     :     Optional[Any]			    =       """align_text_model"""





					def __init__(						self    :  List[str] ,					__lowercase    :  str=3_05_22 ,					__lowercase    :  int=7_68 ,					__lowercase    :  Tuple=12 ,					__lowercase    :  Union[str, Any]=12 ,					__lowercase    :  Dict=30_72 ,					__lowercase    :  Any="gelu" ,					__lowercase    :  Any=0.1 ,					__lowercase    :  Tuple=0.1 ,					__lowercase    :  Tuple=5_12 ,					__lowercase    :  Dict=2 ,					__lowercase    :  str=0.02 ,					__lowercase    :  Dict=1e-12 ,					__lowercase    :  int=0 ,					__lowercase    :  Any="absolute" ,					__lowercase    :  int=True ,					**__lowercase    :  List[str] ,					):






						'''simple docstring'''







						super().__init__(**snake_case_		)

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





					@classmethod
					def        SCREAMING_SNAKE_CASE							(						cls    :  Union[str, Any] ,					__lowercase    :  int ,					**__lowercase    :  str		):






						'''simple docstring'''







						cls._set_token_in_kwargs(snake_case_		)

						UpperCAmelCase_								=     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":
							UpperCAmelCase_								=     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   _UpperCamelCase  (       _snake_case  ):







					'''simple docstring'''

					lowerCamelCase     :     Optional[Any]			    =       """align_vision_model"""





					def __init__(						self    :  int ,					__lowercase    :  Any = 3 ,					__lowercase    :  Dict = 6_00 ,					__lowercase    :  List[Any] = 2.0 ,					__lowercase    :  Optional[int] = 3.1 ,					__lowercase    :  int = 8 ,					__lowercase    :  int = [3, 3, 5, 3, 5, 5, 3] ,					__lowercase    :  Optional[int] = [32, 16, 24, 40, 80, 1_12, 1_92] ,					__lowercase    :  List[str] = [16, 24, 40, 80, 1_12, 1_92, 3_20] ,					__lowercase    :  str = [] ,					__lowercase    :  Any = [1, 2, 2, 2, 1, 2, 1] ,					__lowercase    :  int = [1, 2, 2, 3, 3, 4, 1] ,					__lowercase    :  str = [1, 6, 6, 6, 6, 6, 6] ,					__lowercase    :  Optional[int] = 0.25 ,					__lowercase    :  Union[str, Any] = "swish" ,					__lowercase    :  Tuple = 25_60 ,					__lowercase    :  Tuple = "mean" ,					__lowercase    :  Union[str, Any] = 0.02 ,					__lowercase    :  List[str] = 0.001 ,					__lowercase    :  List[Any] = 0.99 ,					__lowercase    :  str = 0.2 ,					**__lowercase    :  List[Any] ,					):






						'''simple docstring'''







						super().__init__(**snake_case_		)

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





					@classmethod
					def        SCREAMING_SNAKE_CASE							(						cls    :  Any ,					__lowercase    :  int ,					**__lowercase    :  List[str]		):






						'''simple docstring'''







						cls._set_token_in_kwargs(snake_case_		)

						UpperCAmelCase_								=     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":
							UpperCAmelCase_								=     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   _UpperCamelCase  (       _snake_case  ):







					'''simple docstring'''

					lowerCamelCase     :     Tuple			    =       """align"""
					lowerCamelCase     :     Dict			    =       True





					def __init__(						self    :  int ,					__lowercase    :  Union[str, Any]=None ,					__lowercase    :  Optional[Any]=None ,					__lowercase    :  List[str]=6_40 ,					__lowercase    :  List[str]=1.0 ,					__lowercase    :  Tuple=0.02 ,					**__lowercase    :  Any ,					):






						'''simple docstring'''







						super().__init__(**snake_case_		)

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

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

						UpperCAmelCase_								=     AlignTextConfig(**snake_case_		)
						UpperCAmelCase_								=     AlignVisionConfig(**snake_case_		)

						UpperCAmelCase_								=     projection_dim
						UpperCAmelCase_								=     temperature_init_value
						UpperCAmelCase_								=     initializer_range





					@classmethod
					def        SCREAMING_SNAKE_CASE							(						cls    :  Optional[Any] ,					__lowercase    :  Any ,					__lowercase    :  List[Any] ,					**__lowercase    :  Optional[int]		):






						'''simple docstring'''







						return cls(text_config=text_config.to_dict() ,					vision_config=vision_config.to_dict() ,					**snake_case_		)





					def        SCREAMING_SNAKE_CASE							(						self    :  int		):






						'''simple docstring'''







						UpperCAmelCase_								=     copy.deepcopy(self.__dict__		)
						UpperCAmelCase_								=     self.text_config.to_dict()
						UpperCAmelCase_								=     self.vision_config.to_dict()
						UpperCAmelCase_								=     self.__class__.model_type
						return output









from __future__ import annotations




def    A_(			A   ):
	if not nums:
		raise ValueError("""List is empty"""   )
	return sum(A   ) / len(A   )


if __name__ == "__main__":
				import doctest

				doctest.testmod()


