


import copy
import os
from typing import Union

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


_snake_case             =     logging.get_logger(__name__)

_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 	UpperCAmelCase_					(					UpperCamelCase    ):

   '''simple docstring'''




   __A :      Optional[Any]     		=		"altclip_text_model"






   def __init__(		self						,				__A=25_0002						,				__A=1024						,				__A=24						,				__A=16						,				__A=4096						,				__A="gelu"						,				__A=0.1						,				__A=0.1						,				__A=514						,				__A=1						,				__A=0.02						,				__A=0.02						,				__A=1e-05						,				__A=1						,				__A=0						,				__A=2						,				__A="absolute"						,				__A=True						,				__A=768						,				**__A						,				):






     """simple docstring"""





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

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



class 	UpperCAmelCase_					(					UpperCamelCase    ):

   '''simple docstring'''




   __A :      Any     		=		"altclip_vision_model"






   def __init__(		self						,				__A=768						,				__A=3072						,				__A=512						,				__A=12						,				__A=12						,				__A=3						,				__A=224						,				__A=32						,				__A="quick_gelu"						,				__A=1e-5						,				__A=0.0						,				__A=0.02						,				__A=1.0						,				**__A						,				):






     """simple docstring"""





     super().__init__(**__A )

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






   @classmethod
   def _snake_case    (		cls						,				__A						,				**__A ):






     """simple docstring"""





     cls._set_token_in_kwargs(__A )

     lowerCamelCase    ,	lowerCamelCase :					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":
       lowerCamelCase :					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_					(					UpperCamelCase    ):

   '''simple docstring'''




   __A :      str     		=		"altclip"
   __A :      Union[str, Any]     		=		True






   def __init__(		self						,				__A=None						,				__A=None						,				__A=768						,				__A=2.6592						,				**__A ):






     """simple docstring"""





     lowerCamelCase :					Any    =				kwargs.pop("text_config_dict"						,				__A )
     lowerCamelCase :					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:
         lowerCamelCase :					int    =				{}

       # This is the complete result when using `text_config_dict`.
       lowerCamelCase :					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:
             lowerCamelCase :					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:
             lowerCamelCase :					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:
         lowerCamelCase :					Union[str, Any]    =				{}

       # This is the complete result when using `vision_config_dict`.
       lowerCamelCase :					int    =				AltCLIPVisionConfig(**__A ).to_dict()
       # convert keys to string instead of integer
       if "id2label" in _vision_config_dict:
         lowerCamelCase :					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:
             lowerCamelCase :					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:
             lowerCamelCase :					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:
       lowerCamelCase :					List[str]    =				{}
       logger.info("`text_config` is `None`. Initializing the `AltCLIPTextConfig` with default values." )

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

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

     lowerCamelCase :					Tuple    =				projection_dim
     lowerCamelCase :					Tuple    =				logit_scale_init_value
     lowerCamelCase :					Tuple    =				1.0






   @classmethod
   def _snake_case    (		cls						,				__A						,				__A						,				**__A ):






     """simple docstring"""





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






   def _snake_case    (		self ):






     """simple docstring"""





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







from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tokenizers_available, is_torch_available


_snake_case             =     {
    '''configuration_squeezebert''': [
        '''SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''SqueezeBertConfig''',
        '''SqueezeBertOnnxConfig''',
    ],
    '''tokenization_squeezebert''': ['''SqueezeBertTokenizer'''],
}

try:
   if not is_tokenizers_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _snake_case             =     ['''SqueezeBertTokenizerFast''']

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   _snake_case             =     [
       '''SQUEEZEBERT_PRETRAINED_MODEL_ARCHIVE_LIST''',
       '''SqueezeBertForMaskedLM''',
       '''SqueezeBertForMultipleChoice''',
       '''SqueezeBertForQuestionAnswering''',
       '''SqueezeBertForSequenceClassification''',
       '''SqueezeBertForTokenClassification''',
       '''SqueezeBertModel''',
       '''SqueezeBertModule''',
       '''SqueezeBertPreTrainedModel''',
   ]


if TYPE_CHECKING:
   from .configuration_squeezebert import (
       SQUEEZEBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
       SqueezeBertConfig,
       SqueezeBertOnnxConfig,
   )
   from .tokenization_squeezebert import SqueezeBertTokenizer

   try:
      if not is_tokenizers_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .tokenization_squeezebert_fast import SqueezeBertTokenizerFast

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_squeezebert import (
          SQUEEZEBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
          SqueezeBertForMaskedLM,
          SqueezeBertForMultipleChoice,
          SqueezeBertForQuestionAnswering,
          SqueezeBertForSequenceClassification,
          SqueezeBertForTokenClassification,
          SqueezeBertModel,
          SqueezeBertModule,
          SqueezeBertPreTrainedModel,
      )

else:
   import sys

   _snake_case             =     _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)



