





import copy
import os
from typing import Union

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


_SCREAMING_SNAKE_CASE      	=		logging.get_logger(__name__)

_SCREAMING_SNAKE_CASE      	=		{
    """BAAI/AltCLIP""": """https://huggingface.co/BAAI/AltCLIP/resolve/main/config.json""",
    # See all AltCLIP models at https://huggingface.co/models?filter=altclip
}
class SCREAMING_SNAKE_CASE_						(					lowerCAmelCase__					):
						__magic_name__:			List[Any]       =       "altclip_text_model"






						def __init__(      self      :      Optional[Any]		,   _A      :      Any=250002		,   _A      :      Optional[int]=1024		,   _A      :      List[str]=24		,   _A      :      Dict=16		,   _A      :      str=4096		,   _A      :      List[Any]="gelu"		,   _A      :      Optional[int]=0.1		,   _A      :      List[str]=0.1		,   _A      :      Dict=514		,   _A      :      List[Any]=1		,   _A      :      Union[str, Any]=0.0_2		,   _A      :      Dict=0.0_2		,   _A      :      Tuple=1E-05		,   _A      :      int=1		,   _A      :      Union[str, Any]=0		,   _A      :      str=2		,   _A      :      Optional[int]="absolute"		,   _A      :      List[str]=True		,   _A      :      Dict=768		,   **_A      :      int		,   )							->    Any:







							"""simple docstring"""


							super().__init__(pad_token_id=_lowerCamelCase		,   bos_token_id=_lowerCamelCase		,   eos_token_id=_lowerCamelCase		,   **_lowerCamelCase	)

							snake_case_		:			str											=	vocab_size
							snake_case_		:			str											=	hidden_size
							snake_case_		:			str											=	num_hidden_layers
							snake_case_		:			List[Any]											=	num_attention_heads
							snake_case_		:			Union[str, Any]											=	hidden_act
							snake_case_		:			Dict											=	intermediate_size
							snake_case_		:			Optional[Any]											=	hidden_dropout_prob
							snake_case_		:			List[Any]											=	attention_probs_dropout_prob
							snake_case_		:			List[str]											=	max_position_embeddings
							snake_case_		:			Optional[int]											=	type_vocab_size
							snake_case_		:			Optional[Any]											=	initializer_range
							snake_case_		:			Dict											=	initializer_factor
							snake_case_		:			str											=	layer_norm_eps
							snake_case_		:			Any											=	position_embedding_type
							snake_case_		:			List[str]											=	use_cache
							snake_case_		:			List[str]											=	project_dim
class SCREAMING_SNAKE_CASE_						(					lowerCAmelCase__					):
						__magic_name__:			Tuple       =       "altclip_vision_model"






						def __init__(      self      :      Tuple		,   _A      :      Tuple=768		,   _A      :      Any=3072		,   _A      :      List[str]=512		,   _A      :      List[str]=12		,   _A      :      List[Any]=12		,   _A      :      Optional[int]=3		,   _A      :      Any=224		,   _A      :      List[Any]=32		,   _A      :      int="quick_gelu"		,   _A      :      Optional[int]=1E-5		,   _A      :      List[str]=0.0		,   _A      :      List[Any]=0.0_2		,   _A      :      List[Any]=1.0		,   **_A      :      Optional[int]		,   )							->    str:







							"""simple docstring"""


							super().__init__(**_lowerCamelCase	)

							snake_case_		:			List[str]											=	hidden_size
							snake_case_		:			List[Any]											=	intermediate_size
							snake_case_		:			Union[str, Any]											=	projection_dim
							snake_case_		:			Optional[Any]											=	num_hidden_layers
							snake_case_		:			int											=	num_attention_heads
							snake_case_		:			int											=	num_channels
							snake_case_		:			List[str]											=	patch_size
							snake_case_		:			Dict											=	image_size
							snake_case_		:			int											=	initializer_range
							snake_case_		:			Any											=	initializer_factor
							snake_case_		:			Optional[int]											=	attention_dropout
							snake_case_		:			Any											=	layer_norm_eps
							snake_case_		:			List[str]											=	hidden_act






						@classmethod
						def UpperCAmelCase_				(      cls      :      List[Any]		,   _A      :      Dict		,   **_A      :      Optional[int]	)							->    "PretrainedConfig":







							"""simple docstring"""


							cls._set_token_in_kwargs(_lowerCamelCase	)

							snake_case_						,snake_case_		:			str											=	cls.get_config_dict(_lowerCamelCase		,   **_lowerCamelCase	)

							# get the vision config dict if we are loading from AltCLIPConfig
							if config_dict.get('model_type'	) == "altclip":
								snake_case_		:			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 SCREAMING_SNAKE_CASE_						(					lowerCAmelCase__					):
						__magic_name__:			Optional[Any]       =       "altclip"
						__magic_name__:			Union[str, Any]       =       True






						def __init__(      self      :      List[str]		,   _A      :      Optional[int]=None		,   _A      :      List[str]=None		,   _A      :      List[str]=768		,   _A      :      Any=2.6_5_9_2		,   **_A      :      List[Any]	)							->    List[Any]:







							"""simple docstring"""


							snake_case_		:			Union[str, Any]											=	kwargs.pop('text_config_dict'		,   _lowerCamelCase	)
							snake_case_		:			str											=	kwargs.pop('vision_config_dict'		,   _lowerCamelCase	)

							super().__init__(**_lowerCamelCase	)

							# Instead of simply assigning `[text|vision]_config_dict` to `[text|vision]_config`, we use the values in
							# `[text|vision]_config_dict` to update the values in `[text|vision]_config`. The values should be same in most
							# cases, but we don't want to break anything regarding `_config_dict` that existed before commit `8827e1b2`.
							if text_config_dict is not None:
								if text_config is None:
									snake_case_		:			Any											=	{}

								# This is the complete result when using `text_config_dict`.
								snake_case_		:			int											=	AltCLIPTextConfig(**_lowerCamelCase	).to_dict()

								# Give a warning if the values exist in both `_text_config_dict` and `text_config` but being different.
								for key, value in _text_config_dict.items():
									if key in text_config and value != text_config[key] and key not in ["transformers_version"]:
										# If specified in `text_config_dict`
										if key in text_config_dict:
											snake_case_		:			int											=	(
											    F"""`{key}` is found in both `text_config_dict` and `text_config` but with different values. """
											    F"""The value `text_config_dict[\"{key}\"]` will be used instead."""
											)
										# If inferred from default argument values (just to be super careful)
										else:
											snake_case_		:			Tuple											=	(
											    F"""`text_config_dict` is provided which will be used to initialize `AltCLIPTextConfig`. The """
											    F"""value `text_config[\"{key}\"]` will be overriden."""
											)
										logger.warning(_lowerCamelCase	)

            # Update all values in `text_config` with the ones in `_text_config_dict`.
								text_config.update(_text_config_dict	)

							if vision_config_dict is not None:
								if vision_config is None:
									snake_case_		:			Any											=	{}

								# This is the complete result when using `vision_config_dict`.
								snake_case_		:			List[str]											=	AltCLIPVisionConfig(**_lowerCamelCase	).to_dict()
								# convert keys to string instead of integer
								if "id2label" in _vision_config_dict:
									snake_case_		:			Any											=	{
									    str(_lowerCamelCase	): value for key, value in _vision_config_dict['id2label'].items()
									}

								# Give a warning if the values exist in both `_vision_config_dict` and `vision_config` but being different.
								for key, value in _vision_config_dict.items():
									if key in vision_config and value != vision_config[key] and key not in ["transformers_version"]:
										# If specified in `vision_config_dict`
										if key in vision_config_dict:
											snake_case_		:			List[Any]											=	(
											    F"""`{key}` is found in both `vision_config_dict` and `vision_config` but with different """
											    F"""values. The value `vision_config_dict[\"{key}\"]` will be used instead."""
											)
										# If inferred from default argument values (just to be super careful)
										else:
											snake_case_		:			List[Any]											=	(
											    F"""`vision_config_dict` is provided which will be used to initialize `AltCLIPVisionConfig`. """
											    F"""The value `vision_config[\"{key}\"]` will be overriden."""
											)
										logger.warning(_lowerCamelCase	)

            # Update all values in `vision_config` with the ones in `_vision_config_dict`.
								vision_config.update(_vision_config_dict	)

							if text_config is None:
								snake_case_		:			Optional[int]											=	{}
								logger.info('`text_config` is `None`. Initializing the `AltCLIPTextConfig` with default values.'	)

							if vision_config is None:
								snake_case_		:			Union[str, Any]											=	{}
								logger.info('`vision_config` is `None`. initializing the `AltCLIPVisionConfig` with default values.'	)

							snake_case_		:			int											=	AltCLIPTextConfig(**_lowerCamelCase	)
							snake_case_		:			Any											=	AltCLIPVisionConfig(**_lowerCamelCase	)

							snake_case_		:			List[str]											=	projection_dim
							snake_case_		:			Any											=	logit_scale_init_value
							snake_case_		:			str											=	1.0






						@classmethod
						def UpperCAmelCase_				(      cls      :      Any		,   _A      :      List[str]		,   _A      :      List[Any]		,   **_A      :      Union[str, Any]	)							->    List[Any]:







							"""simple docstring"""


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






						def UpperCAmelCase_				(      self      :      List[Any]	)							->    List[Any]:







							"""simple docstring"""


							snake_case_		:			Dict											=	copy.deepcopy(self.__dict__	)
							snake_case_		:			str											=	self.text_config.to_dict()
							snake_case_		:			str											=	self.vision_config.to_dict()
							snake_case_		:			Dict											=	self.__class__.model_type
							return output










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


_SCREAMING_SNAKE_CASE      	=		logging.get_logger(__name__)

_SCREAMING_SNAKE_CASE      	=		{
    """SCUT-DLVCLab/lilt-roberta-en-base""": (
        """https://huggingface.co/SCUT-DLVCLab/lilt-roberta-en-base/resolve/main/config.json"""
    ),
}
class SCREAMING_SNAKE_CASE_						(					snake_case_					):
						__magic_name__:			str       =       "lilt"






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







							"""simple docstring"""


							super().__init__(pad_token_id=_A		,   **_A	)

							snake_case_		:			List[str]											=	vocab_size
							snake_case_		:			Dict											=	hidden_size
							snake_case_		:			Union[str, Any]											=	num_hidden_layers
							snake_case_		:			List[str]											=	num_attention_heads
							snake_case_		:			Tuple											=	hidden_act
							snake_case_		:			Tuple											=	intermediate_size
							snake_case_		:			int											=	hidden_dropout_prob
							snake_case_		:			Tuple											=	attention_probs_dropout_prob
							snake_case_		:			Dict											=	max_position_embeddings
							snake_case_		:			Any											=	type_vocab_size
							snake_case_		:			Union[str, Any]											=	initializer_range
							snake_case_		:			Optional[int]											=	layer_norm_eps
							snake_case_		:			List[str]											=	position_embedding_type
							snake_case_		:			Optional[int]											=	classifier_dropout
							snake_case_		:			Dict											=	channel_shrink_ratio
							snake_case_		:			Tuple											=	max_ad_position_embeddings

