


'''simple docstring'''



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


if TYPE_CHECKING:
	pass

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


_lowercase      :      List[Any]            =					logging.get_logger(__name__)

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






class 	UpperCamelCase__(       __a	):
				__magic_name__    :				Tuple  		=	"""align_text_model"""




				def __init__(		self      :			Union[str, Any]				,   lowerCAmelCase      :			Union[str, Any]=30522				,   lowerCAmelCase      :			Union[str, Any]=768				,   lowerCAmelCase      :			Optional[Any]=12				,   lowerCAmelCase      :			Optional[int]=12				,   lowerCAmelCase      :			Union[str, Any]=3072				,   lowerCAmelCase      :			Optional[Any]="gelu"				,   lowerCAmelCase      :			Optional[int]=0.1				,   lowerCAmelCase      :			List[str]=0.1				,   lowerCAmelCase      :			str=512				,   lowerCAmelCase      :			List[Any]=2				,   lowerCAmelCase      :			Optional[Any]=0.02				,   lowerCAmelCase      :			Optional[int]=1E-12				,   lowerCAmelCase      :			Optional[int]=0				,   lowerCAmelCase      :			Union[str, Any]="absolute"				,   lowerCAmelCase      :			Union[str, Any]=True				,   **lowerCAmelCase      :			Union[str, Any]				,   )->					str:

										"""simple docstring"""




										super().__init__(**a__				)

										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 					a__(		cls      :			Dict				,   lowerCAmelCase      :			Union[str, os.PathLike]				,   **lowerCAmelCase      :			List[str]				)->					List[Any]:

										"""simple docstring"""




										cls._set_token_in_kwargs(a__				)

										UpperCAmelCase    ,    UpperCAmelCase					    =     cls.get_config_dict(a__				,   **a__				)

										# 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(a__				,   **a__				)







class 	UpperCamelCase__(       __a	):
				__magic_name__    :				Optional[int]  		=	"""align_vision_model"""




				def __init__(		self      :			Union[str, Any]				,   lowerCAmelCase      :			int = 3				,   lowerCAmelCase      :			int = 600				,   lowerCAmelCase      :			float = 2.0				,   lowerCAmelCase      :			float = 3.1				,   lowerCAmelCase      :			int = 8				,   lowerCAmelCase      :			List[int] = [3, 3, 5, 3, 5, 5, 3]				,   lowerCAmelCase      :			List[int] = [32, 16, 24, 40, 80, 112, 192]				,   lowerCAmelCase      :			List[int] = [16, 24, 40, 80, 112, 192, 320]				,   lowerCAmelCase      :			List[int] = []				,   lowerCAmelCase      :			List[int] = [1, 2, 2, 2, 1, 2, 1]				,   lowerCAmelCase      :			List[int] = [1, 2, 2, 3, 3, 4, 1]				,   lowerCAmelCase      :			List[int] = [1, 6, 6, 6, 6, 6, 6]				,   lowerCAmelCase      :			float = 0.25				,   lowerCAmelCase      :			str = "swish"				,   lowerCAmelCase      :			int = 2560				,   lowerCAmelCase      :			str = "mean"				,   lowerCAmelCase      :			float = 0.02				,   lowerCAmelCase      :			float = 0.001				,   lowerCAmelCase      :			float = 0.99				,   lowerCAmelCase      :			float = 0.2				,   **lowerCAmelCase      :			int				,   )->					List[Any]:

										"""simple docstring"""




										super().__init__(**a__				)

										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(a__				) * 4





				@classmethod
				def 					a__(		cls      :			Optional[int]				,   lowerCAmelCase      :			Union[str, os.PathLike]				,   **lowerCAmelCase      :			List[str]				)->					Union[str, Any]:

										"""simple docstring"""




										cls._set_token_in_kwargs(a__				)

										UpperCAmelCase    ,    UpperCAmelCase					    =     cls.get_config_dict(a__				,   **a__				)

										# 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(a__				,   **a__				)







class 	UpperCamelCase__(       __a	):
				__magic_name__    :				Tuple  		=	"""align"""
				__magic_name__    :				Dict  		=	True




				def __init__(		self      :			List[str]				,   lowerCAmelCase      :			List[str]=None				,   lowerCAmelCase      :			Optional[int]=None				,   lowerCAmelCase      :			int=640				,   lowerCAmelCase      :			Any=1.0				,   lowerCAmelCase      :			Optional[int]=0.02				,   **lowerCAmelCase      :			str				,   )->					int:

										"""simple docstring"""




										super().__init__(**a__				)

										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(**a__				)
										UpperCAmelCase					    =     AlignVisionConfig(**a__				)

										UpperCAmelCase					    =     projection_dim
										UpperCAmelCase					    =     temperature_init_value
										UpperCAmelCase					    =     initializer_range




				@classmethod
				def 					a__(		cls      :			Tuple				,   lowerCAmelCase      :			AlignTextConfig				,   lowerCAmelCase      :			AlignVisionConfig				,   **lowerCAmelCase      :			str				)->					List[str]:

										"""simple docstring"""




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





				def 					a__(		self      :			Optional[int]				)->					List[str]:

										"""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






'''simple docstring'''



from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_lowercase      :      List[Any]            =					{
    """configuration_x_clip""": [
        """XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """XCLIPConfig""",
        """XCLIPTextConfig""",
        """XCLIPVisionConfig""",
    ],
    """processing_x_clip""": ["""XCLIPProcessor"""],
}

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	_lowercase      :      List[str]            =					[
	    """XCLIP_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """XCLIPModel""",
	    """XCLIPPreTrainedModel""",
	    """XCLIPTextModel""",
	    """XCLIPVisionModel""",
	]

if TYPE_CHECKING:
	from .configuration_x_clip import (
	    XCLIP_PRETRAINED_CONFIG_ARCHIVE_MAP,
	    XCLIPConfig,
	    XCLIPTextConfig,
	    XCLIPVisionConfig,
	)
	from .processing_x_clip import XCLIPProcessor

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_x_clip import (
		    XCLIP_PRETRAINED_MODEL_ARCHIVE_LIST,
		    XCLIPModel,
		    XCLIPPreTrainedModel,
		    XCLIPTextModel,
		    XCLIPVisionModel,
		)

else:
	import sys

	_lowercase      :      List[Any]            =					_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)





