




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


if TYPE_CHECKING:
							pass

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


__lowerCamelCase   :						Optional[Any]				=			logging.get_logger(__name__)

__lowerCamelCase   :						str				=			{
    '''kakaobrain/align-base''': '''https://huggingface.co/kakaobrain/align-base/resolve/main/config.json''',
}


class    lowerCamelCase    (		_lowerCamelCase						):






			'''simple docstring'''





			UpperCamelCase__								='''align_text_model'''

			def __init__( self			:   Any       ,						lowerCamelCase_			:   Dict=30522       ,						lowerCamelCase_			:   List[str]=768       ,						lowerCamelCase_			:   Any=12       ,						lowerCamelCase_			:   str=12       ,						lowerCamelCase_			:   str=3072       ,						lowerCamelCase_			:   str="gelu"       ,						lowerCamelCase_			:   Optional[Any]=0.1       ,						lowerCamelCase_			:   Tuple=0.1       ,						lowerCamelCase_			:   List[str]=512       ,						lowerCamelCase_			:   Optional[int]=2       ,						lowerCamelCase_			:   List[Any]=0.0_2       ,						lowerCamelCase_			:   Dict=1E-12       ,						lowerCamelCase_			:   Union[str, Any]=0       ,						lowerCamelCase_			:   List[Any]="absolute"       ,						lowerCamelCase_			:   Optional[Any]=True       ,						**lowerCamelCase_			:   Any       ,						)						->   int:
								super().__init__(**lowerCamelCase_  )

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


			@classmethod
			def 							UpperCAmelCase__       ( cls			:   Tuple       ,						lowerCamelCase_			:   Dict       ,						**lowerCamelCase_			:   Dict  )						->   Tuple:
								cls._set_token_in_kwargs(lowerCamelCase_  )

								__magic_name__							,    __magic_name__							:	Optional[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":
													__magic_name__							:	int    							=							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    lowerCamelCase    (		_lowerCamelCase						):






			'''simple docstring'''





			UpperCamelCase__								='''align_vision_model'''

			def __init__( self			:   Tuple       ,						lowerCamelCase_			:   Optional[int] = 3       ,						lowerCamelCase_			:   Optional[int] = 600       ,						lowerCamelCase_			:   int = 2.0       ,						lowerCamelCase_			:   int = 3.1       ,						lowerCamelCase_			:   str = 8       ,						lowerCamelCase_			:   Union[str, Any] = [3, 3, 5, 3, 5, 5, 3]       ,						lowerCamelCase_			:   int = [32, 16, 24, 40, 80, 112, 192]       ,						lowerCamelCase_			:   List[str] = [16, 24, 40, 80, 112, 192, 320]       ,						lowerCamelCase_			:   Any = []       ,						lowerCamelCase_			:   List[Any] = [1, 2, 2, 2, 1, 2, 1]       ,						lowerCamelCase_			:   List[str] = [1, 2, 2, 3, 3, 4, 1]       ,						lowerCamelCase_			:   List[str] = [1, 6, 6, 6, 6, 6, 6]       ,						lowerCamelCase_			:   Optional[Any] = 0.2_5       ,						lowerCamelCase_			:   Union[str, Any] = "swish"       ,						lowerCamelCase_			:   Optional[int] = 2560       ,						lowerCamelCase_			:   List[Any] = "mean"       ,						lowerCamelCase_			:   str = 0.0_2       ,						lowerCamelCase_			:   Union[str, Any] = 0.0_0_1       ,						lowerCamelCase_			:   Optional[int] = 0.9_9       ,						lowerCamelCase_			:   Any = 0.2       ,						**lowerCamelCase_			:   Optional[int]       ,						)						->   Optional[int]:
								super().__init__(**lowerCamelCase_  )

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


			@classmethod
			def 							UpperCAmelCase__       ( cls			:   Union[str, Any]       ,						lowerCamelCase_			:   int       ,						**lowerCamelCase_			:   Optional[Any]  )						->   Tuple:
								cls._set_token_in_kwargs(lowerCamelCase_  )

								__magic_name__							,    __magic_name__							:	Union[str, 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":
													__magic_name__							:	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    lowerCamelCase    (		_lowerCamelCase						):






			'''simple docstring'''





			UpperCamelCase__								='''align'''
			UpperCamelCase__								=True

			def __init__( self			:   List[Any]       ,						lowerCamelCase_			:   Any=None       ,						lowerCamelCase_			:   str=None       ,						lowerCamelCase_			:   Union[str, Any]=640       ,						lowerCamelCase_			:   int=1.0       ,						lowerCamelCase_			:   List[Any]=0.0_2       ,						**lowerCamelCase_			:   Tuple       ,						)						->   int:
								super().__init__(**lowerCamelCase_  )

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

								if vision_config is None:
													__magic_name__							:	Union[str, Any]    							=							{}
													logger.info('''vision_config is None. Initializing the AlignVisionConfig with default values.'''  )

								__magic_name__							:	Union[str, Any]    							=							AlignTextConfig(**lowerCamelCase_  )
								__magic_name__							:	Union[str, Any]    							=							AlignVisionConfig(**lowerCamelCase_  )

								__magic_name__							:	List[str]    							=							projection_dim
								__magic_name__							:	Any    							=							temperature_init_value
								__magic_name__							:	str    							=							initializer_range

			@classmethod
			def 							UpperCAmelCase__       ( cls			:   Tuple       ,						lowerCamelCase_			:   List[str]       ,						lowerCamelCase_			:   Dict       ,						**lowerCamelCase_			:   str  )						->   str:
								return cls(text_config=text_config.to_dict()       ,						vision_config=vision_config.to_dict()       ,						**lowerCamelCase_  )


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









from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_torch_available,
)


__lowerCamelCase   :						List[str]				=			{
    '''configuration_roberta_prelayernorm''': [
        '''ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''RobertaPreLayerNormConfig''',
        '''RobertaPreLayerNormOnnxConfig''',
    ],
}

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowerCamelCase   :						Dict				=			[
	    '''ROBERTA_PRELAYERNORM_PRETRAINED_MODEL_ARCHIVE_LIST''',
	    '''RobertaPreLayerNormForCausalLM''',
	    '''RobertaPreLayerNormForMaskedLM''',
	    '''RobertaPreLayerNormForMultipleChoice''',
	    '''RobertaPreLayerNormForQuestionAnswering''',
	    '''RobertaPreLayerNormForSequenceClassification''',
	    '''RobertaPreLayerNormForTokenClassification''',
	    '''RobertaPreLayerNormModel''',
	    '''RobertaPreLayerNormPreTrainedModel''',
	]

try:
	if not is_tf_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowerCamelCase   :						Optional[Any]				=			[
	    '''TF_ROBERTA_PRELAYERNORM_PRETRAINED_MODEL_ARCHIVE_LIST''',
	    '''TFRobertaPreLayerNormForCausalLM''',
	    '''TFRobertaPreLayerNormForMaskedLM''',
	    '''TFRobertaPreLayerNormForMultipleChoice''',
	    '''TFRobertaPreLayerNormForQuestionAnswering''',
	    '''TFRobertaPreLayerNormForSequenceClassification''',
	    '''TFRobertaPreLayerNormForTokenClassification''',
	    '''TFRobertaPreLayerNormMainLayer''',
	    '''TFRobertaPreLayerNormModel''',
	    '''TFRobertaPreLayerNormPreTrainedModel''',
	]

try:
	if not is_flax_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	__lowerCamelCase   :						Optional[Any]				=			[
	    '''FlaxRobertaPreLayerNormForCausalLM''',
	    '''FlaxRobertaPreLayerNormForMaskedLM''',
	    '''FlaxRobertaPreLayerNormForMultipleChoice''',
	    '''FlaxRobertaPreLayerNormForQuestionAnswering''',
	    '''FlaxRobertaPreLayerNormForSequenceClassification''',
	    '''FlaxRobertaPreLayerNormForTokenClassification''',
	    '''FlaxRobertaPreLayerNormModel''',
	    '''FlaxRobertaPreLayerNormPreTrainedModel''',
	]


if TYPE_CHECKING:
	from .configuration_roberta_prelayernorm import (
	    ROBERTA_PRELAYERNORM_PRETRAINED_CONFIG_ARCHIVE_MAP,
	    RobertaPreLayerNormConfig,
	    RobertaPreLayerNormOnnxConfig,
	)

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_roberta_prelayernorm import (
		    ROBERTA_PRELAYERNORM_PRETRAINED_MODEL_ARCHIVE_LIST,
		    RobertaPreLayerNormForCausalLM,
		    RobertaPreLayerNormForMaskedLM,
		    RobertaPreLayerNormForMultipleChoice,
		    RobertaPreLayerNormForQuestionAnswering,
		    RobertaPreLayerNormForSequenceClassification,
		    RobertaPreLayerNormForTokenClassification,
		    RobertaPreLayerNormModel,
		    RobertaPreLayerNormPreTrainedModel,
		)

	try:
		if not is_tf_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_tf_roberta_prelayernorm import (
		    TF_ROBERTA_PRELAYERNORM_PRETRAINED_MODEL_ARCHIVE_LIST,
		    TFRobertaPreLayerNormForCausalLM,
		    TFRobertaPreLayerNormForMaskedLM,
		    TFRobertaPreLayerNormForMultipleChoice,
		    TFRobertaPreLayerNormForQuestionAnswering,
		    TFRobertaPreLayerNormForSequenceClassification,
		    TFRobertaPreLayerNormForTokenClassification,
		    TFRobertaPreLayerNormMainLayer,
		    TFRobertaPreLayerNormModel,
		    TFRobertaPreLayerNormPreTrainedModel,
		)

	try:
		if not is_flax_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_flax_roberta_prelayernorm import (
		    FlaxRobertaPreLayerNormForCausalLM,
		    FlaxRobertaPreLayerNormForMaskedLM,
		    FlaxRobertaPreLayerNormForMultipleChoice,
		    FlaxRobertaPreLayerNormForQuestionAnswering,
		    FlaxRobertaPreLayerNormForSequenceClassification,
		    FlaxRobertaPreLayerNormForTokenClassification,
		    FlaxRobertaPreLayerNormModel,
		    FlaxRobertaPreLayerNormPreTrainedModel,
		)

else:
	import sys

	__lowerCamelCase   :						Dict				=			_LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)



