import copy
import os
from typing import Union

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


_UpperCAmelCase						=		logging.get_logger(__name__)

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





class UpperCAmelCase						(					__A  ):


				'''simple docstring'''






				lowerCamelCase_    =					"altclip_text_model"
				def __init__(						self		,	lowercase=2_5_0_0_0_2		,	lowercase=1_0_2_4		,	lowercase=2_4		,	lowercase=1_6		,	lowercase=4_0_9_6		,	lowercase="gelu"		,	lowercase=0.1		,	lowercase=0.1		,	lowercase=5_1_4		,	lowercase=1		,	lowercase=0.02		,	lowercase=0.02		,	lowercase=1E-05		,	lowercase=1		,	lowercase=0		,	lowercase=2		,	lowercase="absolute"		,	lowercase=True		,	lowercase=7_6_8		,	**lowercase		,	):



						"""simple docstring"""





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

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





class UpperCAmelCase						(					__A  ):


				'''simple docstring'''






				lowerCamelCase_    =					"altclip_vision_model"
				def __init__(						self		,	lowercase=7_6_8		,	lowercase=3_0_7_2		,	lowercase=5_1_2		,	lowercase=1_2		,	lowercase=1_2		,	lowercase=3		,	lowercase=2_2_4		,	lowercase=3_2		,	lowercase="quick_gelu"		,	lowercase=1E-5		,	lowercase=0.0		,	lowercase=0.02		,	lowercase=1.0		,	**lowercase		,	):



						"""simple docstring"""





						super().__init__(**__A					)

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







				@classmethod
				def   lowerCAmelCase_   (						cls		,	lowercase		,	**lowercase					):



						"""simple docstring"""





						cls._set_token_in_kwargs(__A					)

						A_		:				str     =      cls.get_config_dict(__A		,	**__A					)

						# get the vision config dict if we are loading from AltCLIPConfig
						if config_dict.get('model_type'					) == "altclip":
								A_		:				Tuple     =      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  ):


				'''simple docstring'''






				lowerCamelCase_    =					"altclip"
				lowerCamelCase_    =					True
				def __init__(						self		,	lowercase=None		,	lowercase=None		,	lowercase=7_6_8		,	lowercase=2.6592		,	**lowercase					):



						"""simple docstring"""





						A_		:				Any     =      kwargs.pop('text_config_dict'		,	__A					)
						A_		:				str     =      kwargs.pop('vision_config_dict'		,	__A					)

						super().__init__(**__A					)

						# 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:
										A_		:				int     =      {}

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

												 # 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:
										A_		:				Union[str, Any]     =      {}

								# This is the complete result when using `vision_config_dict`.
								A_		:				int     =      AltCLIPVisionConfig(**__A					).to_dict()
								# convert keys to string instead of integer
								if "id2label" in _vision_config_dict:
										A_		:				str     =      {
										    str(__A					): 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:
														A_		:				Union[str, 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:
														A_		:				List[str]     =      (
														    F'''`vision_config_dict` is provided which will be used to initialize `AltCLIPVisionConfig`. '''
														    F'''The value `vision_config[\"{key}\"]` will be overriden.'''
														)
												logger.warning(__A					)

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

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

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

						A_		:				List[Any]     =      AltCLIPTextConfig(**__A					)
						A_		:				Tuple     =      AltCLIPVisionConfig(**__A					)

						A_		:				Tuple     =      projection_dim
						A_		:				Tuple     =      logit_scale_init_value
						A_		:				Tuple     =      1.0
				@classmethod
				def   lowerCAmelCase_   (						cls		,	lowercase		,	lowercase		,	**lowercase					):



						"""simple docstring"""





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







				def   lowerCAmelCase_   (						self					):



						"""simple docstring"""





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










def 		lowercase_(  SCREAMING_SNAKE_CASE_	):


  '''simple docstring'''

  if divisor % 5 == 0 or divisor % 2 == 0:
    return 0
  lowerCamelCase :					List[Any]    =				1
  lowerCamelCase :					Union[str, Any]    =				1
  while repunit:
    lowerCamelCase :					Union[str, Any]    =				(10 * repunit + 1) % divisor
    repunit_index += 1
  return repunit_index






def 		lowercase_(  SCREAMING_SNAKE_CASE_ = 1000000	):


  '''simple docstring'''

  lowerCamelCase :					List[str]    =				limit - 1
  if divisor % 2 == 0:
    divisor += 1
  while least_divisible_repunit(SCREAMING_SNAKE_CASE_	) <= limit:
    divisor += 2
  return divisor


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



