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


if TYPE_CHECKING:
					pass

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


SCREAMING_SNAKE_CASE							:Optional[int]										=    logging.get_logger(__name__)

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





class 							UpperCAmelCase				(  __SCREAMING_SNAKE_CASE  ):




	'''simple docstring'''





	snake_case_    =					"align_text_model"






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

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







	@classmethod
	def     UpperCamelCase_  (	cls :			str							,A :			Union[str, os.PathLike]							,**A :			int			):
					cls._set_token_in_kwargs(A			)

					__A      ,							__A             =			cls.get_config_dict(A							,**A			)

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




	'''simple docstring'''





	snake_case_    =					"align_vision_model"






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

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







	@classmethod
	def     UpperCamelCase_  (	cls :			str							,A :			Union[str, os.PathLike]							,**A :			List[Any]			):
					cls._set_token_in_kwargs(A			)

					__A      ,							__A             =			cls.get_config_dict(A							,**A			)

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




	'''simple docstring'''





	snake_case_    =					"align"
	snake_case_    =					True






	def __init__(	self :			Any							,A :			str=None							,A :			int=None							,A :			Any=6_40							,A :			int=1.0							,A :			Union[str, Any]=0.02							,**A :			List[str]							,):
					super().__init__(**A			)

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

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

					__A             =			AlignTextConfig(**A			)
					__A             =			AlignVisionConfig(**A			)

					__A             =			projection_dim
					__A             =			temperature_init_value
					__A             =			initializer_range






	@classmethod
	def     UpperCamelCase_  (	cls :			List[str]							,A :			AlignTextConfig							,A :			AlignVisionConfig							,**A :			str			):
					return cls(text_config=text_config.to_dict()							,vision_config=vision_config.to_dict()							,**A			)







	def     UpperCamelCase_  (	self :			List[Any]			):
					__A             =			copy.deepcopy(self.__dict__			)
					__A             =			self.text_config.to_dict()
					__A             =			self.vision_config.to_dict()
					__A             =			self.__class__.model_type
					return output


import copy
from dataclasses import dataclass, field
from typing import ClassVar, Dict

from ..features import ClassLabel, Features, Value
from .base import TaskTemplate





@dataclass(frozen=__SCREAMING_SNAKE_CASE  )
class 							UpperCAmelCase				(  __SCREAMING_SNAKE_CASE  ):




	'''simple docstring'''





	snake_case_    =					field(default="text-classification"      ,      metadata={"include_in_asdict_even_if_is_default": True}  )
	snake_case_    =					Features({"text": Value("string"  )}  )
	snake_case_    =					Features({"labels": ClassLabel}  )
	snake_case_    =					"text"
	snake_case_    =					"labels"






	def     UpperCamelCase_  (	self :			Optional[Any]							,A :			Dict			):
					if self.label_column not in features:
									raise ValueError(f'''Column {self.label_column} is not present in features.'''			)
					if not isinstance(features[self.label_column]							,A			):
									raise ValueError(f'''Column {self.label_column} is not a ClassLabel.'''			)
					__A             =			copy.deepcopy(self			)
					__A             =			self.label_schema.copy()
					__A             =			features[self.label_column]
					__A             =			label_schema
					return task_template







	@property
	def     UpperCamelCase_  (	self :			Dict			):
					return {
					    self.text_column: "text",
					    self.label_column: "labels",
					}
