




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 			a__    (					snake_case__      ):
						_a							:    List[Any]					=    """altclip_text_model"""






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




											"""simple docstring"""



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

											__lowerCAmelCase				   =       vocab_size
											__lowerCAmelCase				   =       hidden_size
											__lowerCAmelCase				   =       num_hidden_layers
											__lowerCAmelCase				   =       num_attention_heads
											__lowerCAmelCase				   =       hidden_act
											__lowerCAmelCase				   =       intermediate_size
											__lowerCAmelCase				   =       hidden_dropout_prob
											__lowerCAmelCase				   =       attention_probs_dropout_prob
											__lowerCAmelCase				   =       max_position_embeddings
											__lowerCAmelCase				   =       type_vocab_size
											__lowerCAmelCase				   =       initializer_range
											__lowerCAmelCase				   =       initializer_factor
											__lowerCAmelCase				   =       layer_norm_eps
											__lowerCAmelCase				   =       position_embedding_type
											__lowerCAmelCase				   =       use_cache
											__lowerCAmelCase				   =       project_dim






class 			a__    (					snake_case__      ):
						_a							:    List[Any]					=    """altclip_vision_model"""






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




											"""simple docstring"""



											super().__init__(**_A			)

											__lowerCAmelCase				   =       hidden_size
											__lowerCAmelCase				   =       intermediate_size
											__lowerCAmelCase				   =       projection_dim
											__lowerCAmelCase				   =       num_hidden_layers
											__lowerCAmelCase				   =       num_attention_heads
											__lowerCAmelCase				   =       num_channels
											__lowerCAmelCase				   =       patch_size
											__lowerCAmelCase				   =       image_size
											__lowerCAmelCase				   =       initializer_range
											__lowerCAmelCase				   =       initializer_factor
											__lowerCAmelCase				   =       attention_dropout
											__lowerCAmelCase				   =       layer_norm_eps
											__lowerCAmelCase				   =       hidden_act






						@classmethod
						def 				__SCREAMING_SNAKE_CASE(   cls		,			_A		,			**_A			):




											"""simple docstring"""



											cls._set_token_in_kwargs(_A			)

											__lowerCAmelCase   ,							__lowerCAmelCase				   =       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				   =       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 			a__    (					snake_case__      ):
						_a							:    Any					=    """altclip"""
						_a							:    Optional[int]					=    True






						def __init__(   self		,			_A=None		,			_A=None		,			_A=7_6_8		,			_A=2.65_92		,			**_A			):




											"""simple docstring"""



											__lowerCAmelCase				   =       kwargs.pop("text_config_dict"		,			_A			)
											__lowerCAmelCase				   =       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				   =       {}

																# This is the complete result when using `text_config_dict`.
																__lowerCAmelCase				   =       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				   =       (
																															    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				   =       (
																															    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				   =       {}

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

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

											__lowerCAmelCase				   =       AltCLIPTextConfig(**_A			)
											__lowerCAmelCase				   =       AltCLIPVisionConfig(**_A			)

											__lowerCAmelCase				   =       projection_dim
											__lowerCAmelCase				   =       logit_scale_init_value
											__lowerCAmelCase				   =       1.0






						@classmethod
						def 				__SCREAMING_SNAKE_CASE(   cls		,			_A		,			_A		,			**_A			):




											"""simple docstring"""



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






						def 				__SCREAMING_SNAKE_CASE(   self			):




											"""simple docstring"""



											__lowerCAmelCase				   =       copy.deepcopy(self.__dict__			)
											__lowerCAmelCase				   =       self.text_config.to_dict()
											__lowerCAmelCase				   =       self.vision_config.to_dict()
											__lowerCAmelCase				   =       self.__class__.model_type
											return output






'''simple docstring'''







import warnings

from ...utils import logging
from .image_processing_beit import BeitImageProcessor


__lowerCAmelCase         =    logging.get_logger(__name__)







class UpperCAmelCase__	( lowercase__	):





  """simple docstring"""

  def __init__(		self      :     int							,*_a      :     Optional[int]							,**_a      :     str       ):


     '''simple docstring'''






     warnings.warn(
         'The class BeitFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please'
         ' use BeitImageProcessor instead.'							,_a							,)
     super().__init__(*_a							,**_a       )



