
import copy
import os
from typing import Union

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


A__      :	Optional[Any]          =    logging.get_logger(__name__)

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







class   _lowercase						(       UpperCAmelCase_				):


     '''simple docstring'''





     _A								=							'altclip_text_model'



     def __init__(      self ,			__UpperCamelCase=25_00_02 ,			__UpperCamelCase=10_24 ,			__UpperCamelCase=24 ,			__UpperCamelCase=16 ,			__UpperCamelCase=40_96 ,			__UpperCamelCase="gelu" ,			__UpperCamelCase=0.1 ,			__UpperCamelCase=0.1 ,			__UpperCamelCase=5_14 ,			__UpperCamelCase=1 ,			__UpperCamelCase=0.02 ,			__UpperCamelCase=0.02 ,			__UpperCamelCase=1E-05 ,			__UpperCamelCase=1 ,			__UpperCamelCase=0 ,			__UpperCamelCase=2 ,			__UpperCamelCase="absolute" ,			__UpperCamelCase=True ,			__UpperCamelCase=7_68 ,			**__UpperCamelCase ,			)->					Union[str, Any]:
          super().__init__(pad_token_id=_lowercase ,			bos_token_id=_lowercase ,			eos_token_id=_lowercase ,			**_lowercase  )

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







class   _lowercase						(       UpperCAmelCase_				):


     '''simple docstring'''





     _A								=							'altclip_vision_model'



     def __init__(      self ,			__UpperCamelCase=7_68 ,			__UpperCamelCase=30_72 ,			__UpperCamelCase=5_12 ,			__UpperCamelCase=12 ,			__UpperCamelCase=12 ,			__UpperCamelCase=3 ,			__UpperCamelCase=2_24 ,			__UpperCamelCase=32 ,			__UpperCamelCase="quick_gelu" ,			__UpperCamelCase=1E-5 ,			__UpperCamelCase=0.0 ,			__UpperCamelCase=0.02 ,			__UpperCamelCase=1.0 ,			**__UpperCamelCase ,			)->					Tuple:
          super().__init__(**_lowercase  )

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



     @classmethod
     def  lowerCAmelCase__       (      cls ,			__UpperCamelCase ,			**__UpperCamelCase  )->					Optional[Any]:
          cls._set_token_in_kwargs(_lowercase  )

          UpperCAmelCase__							,	UpperCAmelCase__							: List[str] 							=						cls.get_config_dict(_lowercase ,			**_lowercase  )

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







class   _lowercase						(       UpperCAmelCase_				):


     '''simple docstring'''





     _A								=							'altclip'
     _A								=							True



     def __init__(      self ,			__UpperCamelCase=None ,			__UpperCamelCase=None ,			__UpperCamelCase=7_68 ,			__UpperCamelCase=2.6592 ,			**__UpperCamelCase  )->					Union[str, Any]:
          # If `_config_dict` exist, we use them for the backward compatibility.
          # We pop out these 2 attributes before calling `super().__init__` to avoid them being saved (which causes a lot
          # of confusion!).
          UpperCAmelCase__							: Optional[int] 							=						kwargs.pop("text_config_dict" ,			_lowercase  )
          UpperCAmelCase__							: Optional[Any] 							=						kwargs.pop("vision_config_dict" ,			_lowercase  )

          super().__init__(**_lowercase  )

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

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

            # 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:
                    UpperCAmelCase__							: Optional[int] 							=						{}

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

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

          if text_config is None:
               UpperCAmelCase__							: Any 							=						{}
               logger.info("`text_config` is `None`. Initializing the `AltCLIPTextConfig` with default values."  )

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

          UpperCAmelCase__							: Any 							=						AltCLIPTextConfig(**_lowercase  )
          UpperCAmelCase__							: Optional[Any] 							=						AltCLIPVisionConfig(**_lowercase  )

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



     @classmethod
     def  lowerCAmelCase__       (      cls ,			__UpperCamelCase ,			__UpperCamelCase ,			**__UpperCamelCase  )->					Dict:
          return cls(text_config=text_config.to_dict() ,			vision_config=vision_config.to_dict() ,			**_lowercase  )



     def  lowerCAmelCase__       (      self  )->					str:
          UpperCAmelCase__							: Any 							=						copy.deepcopy(self.__dict__  )
          UpperCAmelCase__							: List[str] 							=						self.text_config.to_dict()
          UpperCAmelCase__							: List[Any] 							=						self.vision_config.to_dict()
          UpperCAmelCase__							: Union[str, Any] 							=						self.__class__.model_type
          return output





"""simple docstring"""




import math



def 							a__ (				lowerCAmelCase	:       int		):






     '''simple docstring'''

     if 1 < number < 4:
          # 2 and 3 are primes
          return True
     elif number < 2 or number % 2 == 0 or number % 3 == 0:
          # Negatives, 0, 1, all even numbers, all multiples of 3 are not primes
          return False

     # All primes number are in format of 6k +/- 1
     for i in range(5       ,    int(math.sqrt(lowerCAmelCase		) + 1		)       ,    6		):
          if number % i == 0 or number % (i + 2) == 0:
               return False
     return True



def 							a__ (				lowerCAmelCase	:       int = 1_0001		):






     '''simple docstring'''

     try:
          UpperCAmelCase__							: List[str] 							=						int(lowerCAmelCase		)
     except (TypeError, ValueError):
          raise TypeError("Parameter nth must be int or castable to int."		) from None
     if nth <= 0:
          raise ValueError("Parameter nth must be greater than or equal to one."		)
     UpperCAmelCase__							: list[int] 							=						[]
     UpperCAmelCase__							: str 							=						2
     while len(lowerCAmelCase		) < nth:
          if is_prime(lowerCAmelCase		):
               primes.append(lowerCAmelCase		)
               num += 1
          else:
               num += 1
     return primes[len(lowerCAmelCase		) - 1]


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



