

"""simple docstring"""


import copy
import os
from typing import Union

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


__A						   =			logging.get_logger(__name__)

__A						   =			{
    "BAAI/AltCLIP": "https://huggingface.co/BAAI/AltCLIP/resolve/main/config.json",
    # See all AltCLIP models at https://huggingface.co/models?filter=altclip
}





class     snake_case	(				__snake_case  ):
				SCREAMING_SNAKE_CASE_   :      Optional[int]         =  """altclip_text_model"""

				def __init__(	self							:				str     ,  UpperCamelCase__							:				Any=2_5_0_0_0_2     ,  UpperCamelCase__							:				Union[str, Any]=1_0_2_4     ,  UpperCamelCase__							:				List[Any]=2_4     ,  UpperCamelCase__							:				Union[str, Any]=1_6     ,  UpperCamelCase__							:				int=4_0_9_6     ,  UpperCamelCase__							:				int="gelu"     ,  UpperCamelCase__							:				str=0.1     ,  UpperCamelCase__							:				Any=0.1     ,  UpperCamelCase__							:				Union[str, Any]=5_1_4     ,  UpperCamelCase__							:				int=1     ,  UpperCamelCase__							:				List[str]=0.02     ,  UpperCamelCase__							:				str=0.02     ,  UpperCamelCase__							:				Optional[Any]=1e-05     ,  UpperCamelCase__							:				Any=1     ,  UpperCamelCase__							:				Union[str, Any]=0     ,  UpperCamelCase__							:				Dict=2     ,  UpperCamelCase__							:				str="absolute"     ,  UpperCamelCase__							:				Union[str, Any]=True     ,  UpperCamelCase__							:				Union[str, Any]=7_6_8     ,  **UpperCamelCase__							:				List[Any]     ,  )->   Tuple:



						'''simple docstring'''


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

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





class     snake_case	(				__snake_case  ):
				SCREAMING_SNAKE_CASE_   :      Dict         =  """altclip_vision_model"""

				def __init__(	self							:				Dict     ,  UpperCamelCase__							:				Dict=7_6_8     ,  UpperCamelCase__							:				int=3_0_7_2     ,  UpperCamelCase__							:				Optional[int]=5_1_2     ,  UpperCamelCase__							:				int=1_2     ,  UpperCamelCase__							:				str=1_2     ,  UpperCamelCase__							:				List[str]=3     ,  UpperCamelCase__							:				Dict=2_2_4     ,  UpperCamelCase__							:				Any=3_2     ,  UpperCamelCase__							:				List[str]="quick_gelu"     ,  UpperCamelCase__							:				Optional[int]=1e-5     ,  UpperCamelCase__							:				Union[str, Any]=0.0     ,  UpperCamelCase__							:				Union[str, Any]=0.02     ,  UpperCamelCase__							:				Any=1.0     ,  **UpperCamelCase__							:				Optional[int]     ,  )->   Union[str, Any]:



						'''simple docstring'''


						super().__init__(**UpperCamelCase__)

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




				@classmethod
				def 							lowercase_     (	cls							:				int     ,  UpperCamelCase__							:				Union[str, os.PathLike]     ,  **UpperCamelCase__							:				Optional[int])->   "PretrainedConfig":



						'''simple docstring'''


						cls._set_token_in_kwargs(UpperCamelCase__)

						__lowerCAmelCase      , __lowerCAmelCase:       Optional[Any]          =			cls.get_config_dict(UpperCamelCase__     ,  **UpperCamelCase__)

						# get the vision config dict if we are loading from AltCLIPConfig
						if config_dict.get("model_type") == "altclip":
								__lowerCAmelCase:       str          =			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(UpperCamelCase__     ,  **UpperCamelCase__)





class     snake_case	(				__snake_case  ):
				SCREAMING_SNAKE_CASE_   :      Optional[Any]         =  """altclip"""
				SCREAMING_SNAKE_CASE_   :      str         =  True

				def __init__(	self							:				Tuple     ,  UpperCamelCase__							:				Optional[int]=None     ,  UpperCamelCase__							:				List[str]=None     ,  UpperCamelCase__							:				Dict=7_6_8     ,  UpperCamelCase__							:				Any=2.6592     ,  **UpperCamelCase__							:				str)->   Tuple:



						'''simple docstring'''


						__lowerCAmelCase:       str          =			kwargs.pop("text_config_dict"     ,  UpperCamelCase__)
						__lowerCAmelCase:       Dict          =			kwargs.pop("vision_config_dict"     ,  UpperCamelCase__)

						super().__init__(**UpperCamelCase__)

						# 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:
										__lowerCAmelCase:       List[Any]          =			{}

								# This is the complete result when using `text_config_dict`.
								__lowerCAmelCase:       Tuple          =			AltCLIPTextConfig(**UpperCamelCase__).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:
														__lowerCAmelCase:       str          =			(
														    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:
														__lowerCAmelCase:       Dict          =			(
														    f"`text_config_dict` is provided which will be used to initialize `AltCLIPTextConfig`. The "
														    f"value `text_config[\"{key}\"]` will be overriden."
														)
												logger.warning(UpperCamelCase__)

            # 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:
										__lowerCAmelCase:       str          =			{}

								# This is the complete result when using `vision_config_dict`.
								__lowerCAmelCase:       Dict          =			AltCLIPVisionConfig(**UpperCamelCase__).to_dict()
								# convert keys to string instead of integer
								if "id2label" in _vision_config_dict:
										__lowerCAmelCase:       int          =			{
										    str(UpperCamelCase__): 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:
														__lowerCAmelCase:       int          =			(
														    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:
														__lowerCAmelCase:       Optional[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(UpperCamelCase__)

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

						if text_config is None:
								__lowerCAmelCase:       List[str]          =			{}
								logger.info("`text_config` is `None`. Initializing the `AltCLIPTextConfig` with default values.")

						if vision_config is None:
								__lowerCAmelCase:       Tuple          =			{}
								logger.info("`vision_config` is `None`. initializing the `AltCLIPVisionConfig` with default values.")

						__lowerCAmelCase:       str          =			AltCLIPTextConfig(**UpperCamelCase__)
						__lowerCAmelCase:       str          =			AltCLIPVisionConfig(**UpperCamelCase__)

						__lowerCAmelCase:       Any          =			projection_dim
						__lowerCAmelCase:       Any          =			logit_scale_init_value
						__lowerCAmelCase:       int          =			1.0

				@classmethod
				def 							lowercase_     (	cls							:				Dict     ,  UpperCamelCase__							:				AltCLIPTextConfig     ,  UpperCamelCase__							:				AltCLIPVisionConfig     ,  **UpperCamelCase__							:				int)->   Tuple:



						'''simple docstring'''


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




				def 							lowercase_     (	self							:				List[Any])->   str:



						'''simple docstring'''


						__lowerCAmelCase:       Dict          =			copy.deepcopy(self.__dict__)
						__lowerCAmelCase:       List[str]          =			self.text_config.to_dict()
						__lowerCAmelCase:       str          =			self.vision_config.to_dict()
						__lowerCAmelCase:       Any          =			self.__class__.model_type
						return output





"""simple docstring"""


from __future__ import annotations






def     a__    (    __SCREAMING_SNAKE_CASE )	->	bool:
		__lowerCAmelCase:       Tuple          =			str(__SCREAMING_SNAKE_CASE )
		return len(__SCREAMING_SNAKE_CASE ) == 9 and set(__SCREAMING_SNAKE_CASE ) == set("123456789" )






def     a__    (    )	->	int | None:
		for base_num in range(9_9_9_9					, 4_9_9_9					, -1 ):
				__lowerCAmelCase:       Tuple          =			1_0_0_0_0_2 * base_num
				if is_9_pandigital(__SCREAMING_SNAKE_CASE ):
						return candidate

		for base_num in range(3_3_3					, 9_9					, -1 ):
				__lowerCAmelCase:       int          =			1_0_0_2_0_0_3 * base_num
				if is_9_pandigital(__SCREAMING_SNAKE_CASE ):
						return candidate

		return None


if __name__ == "__main__":
			print(F'''{solution() = }''')


