


"""simple docstring"""



import unittest

from transformers import AlbertConfig, is_torch_available
from transformers.models.auto import get_values
from transformers.testing_utils import require_torch, slow, torch_device

from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
   import torch

   from transformers import (
       MODEL_FOR_PRETRAINING_MAPPING,
       AlbertForMaskedLM,
       AlbertForMultipleChoice,
       AlbertForPreTraining,
       AlbertForQuestionAnswering,
       AlbertForSequenceClassification,
       AlbertForTokenClassification,
       AlbertModel,
   )
   from transformers.models.albert.modeling_albert import ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST







class _lowerCAmelCase    :







   def __init__(     self						,     UpperCamelCase__						,     UpperCamelCase__=13						,     UpperCamelCase__=7						,     UpperCamelCase__=True						,     UpperCamelCase__=True						,     UpperCamelCase__=True						,     UpperCamelCase__=True						,     UpperCamelCase__=99						,     UpperCamelCase__=16						,     UpperCamelCase__=36						,     UpperCamelCase__=6						,     UpperCamelCase__=6						,     UpperCamelCase__=6						,     UpperCamelCase__=37						,     UpperCamelCase__="gelu"						,     UpperCamelCase__=0.1						,     UpperCamelCase__=0.1						,     UpperCamelCase__=512						,     UpperCamelCase__=16						,     UpperCamelCase__=2						,     UpperCamelCase__=0.02						,     UpperCamelCase__=3						,     UpperCamelCase__=4						,     UpperCamelCase__=None						,     )     ->		Optional[Any]:

       '''simple docstring'''




       snake_case   :				Union[str, Any]				 =   parent
       snake_case   :				int				 =   batch_size
       snake_case   :				Dict				 =   seq_length
       snake_case   :				Union[str, Any]				 =   is_training
       snake_case   :				Union[str, Any]				 =   use_input_mask
       snake_case   :				int				 =   use_token_type_ids
       snake_case   :				str				 =   use_labels
       snake_case   :				int				 =   vocab_size
       snake_case   :				Optional[Any]				 =   embedding_size
       snake_case   :				str				 =   hidden_size
       snake_case   :				Optional[int]				 =   num_hidden_layers
       snake_case   :				str				 =   num_hidden_groups
       snake_case   :				List[Any]				 =   num_attention_heads
       snake_case   :				List[Any]				 =   intermediate_size
       snake_case   :				List[str]				 =   hidden_act
       snake_case   :				int				 =   hidden_dropout_prob
       snake_case   :				Optional[int]				 =   attention_probs_dropout_prob
       snake_case   :				List[str]				 =   max_position_embeddings
       snake_case   :				List[Any]				 =   type_vocab_size
       snake_case   :				List[str]				 =   type_sequence_label_size
       snake_case   :				Optional[Any]				 =   initializer_range
       snake_case   :				Tuple				 =   num_labels
       snake_case   :				str				 =   num_choices
       snake_case   :				Tuple				 =   scope







   def 			lowerCamelCase		(     self						)     ->		Optional[Any]:

       '''simple docstring'''




       snake_case   :				List[str]				 =   ids_tensor([self.batch_size, self.seq_length]						,     self.vocab_size						)

       snake_case   :				Optional[Any]				 =   None
       if self.use_input_mask:
           snake_case   :				Dict				 =   random_attention_mask([self.batch_size, self.seq_length]						)

       snake_case   :				List[Any]				 =   None
       if self.use_token_type_ids:
           snake_case   :				Optional[Any]				 =   ids_tensor([self.batch_size, self.seq_length]						,     self.type_vocab_size						)

       snake_case   :				List[str]				 =   None
       snake_case   :				Tuple				 =   None
       snake_case   :				Any				 =   None
       if self.use_labels:
           snake_case   :				int				 =   ids_tensor([self.batch_size]						,     self.type_sequence_label_size						)
           snake_case   :				Any				 =   ids_tensor([self.batch_size, self.seq_length]						,     self.num_labels						)
           snake_case   :				List[str]				 =   ids_tensor([self.batch_size]						,     self.num_choices						)

       snake_case   :				List[str]				 =   self.get_config()

       return config, input_ids, token_type_ids, input_mask, sequence_labels, token_labels, choice_labels







   def 			lowerCamelCase		(     self						)     ->		Tuple:

       '''simple docstring'''




       return AlbertConfig(
           vocab_size=self.vocab_size						,     hidden_size=self.hidden_size						,     num_hidden_layers=self.num_hidden_layers						,     num_attention_heads=self.num_attention_heads						,     intermediate_size=self.intermediate_size						,     hidden_act=self.hidden_act						,     hidden_dropout_prob=self.hidden_dropout_prob						,     attention_probs_dropout_prob=self.attention_probs_dropout_prob						,     max_position_embeddings=self.max_position_embeddings						,     type_vocab_size=self.type_vocab_size						,     initializer_range=self.initializer_range						,     num_hidden_groups=self.num_hidden_groups						,     )







   def 			lowerCamelCase		(     self						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						)     ->		Dict:

       '''simple docstring'''




       snake_case   :				Dict				 =   AlbertModel(config=_a						)
       model.to(_a						)
       model.eval()
       snake_case   :				List[Any]				 =   model(_a						,     attention_mask=_a						,     token_type_ids=_a						)
       snake_case   :				Union[str, Any]				 =   model(_a						,     token_type_ids=_a						)
       snake_case   :				str				 =   model(_a						)
       self.parent.assertEqual(result.last_hidden_state.shape						,     (self.batch_size, self.seq_length, self.hidden_size)						)
       self.parent.assertEqual(result.pooler_output.shape						,     (self.batch_size, self.hidden_size)						)







   def 			lowerCamelCase		(     self						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						)     ->		List[Any]:

       '''simple docstring'''




       snake_case   :				Any				 =   AlbertForPreTraining(config=_a						)
       model.to(_a						)
       model.eval()
       snake_case   :				Dict				 =   model(
           _a						,     attention_mask=_a						,     token_type_ids=_a						,     labels=_a						,     sentence_order_label=_a						,     )
       self.parent.assertEqual(result.prediction_logits.shape						,     (self.batch_size, self.seq_length, self.vocab_size)						)
       self.parent.assertEqual(result.sop_logits.shape						,     (self.batch_size, config.num_labels)						)







   def 			lowerCamelCase		(     self						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						)     ->		Tuple:

       '''simple docstring'''




       snake_case   :				Dict				 =   AlbertForMaskedLM(config=_a						)
       model.to(_a						)
       model.eval()
       snake_case   :				Tuple				 =   model(_a						,     attention_mask=_a						,     token_type_ids=_a						,     labels=_a						)
       self.parent.assertEqual(result.logits.shape						,     (self.batch_size, self.seq_length, self.vocab_size)						)







   def 			lowerCamelCase		(     self						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						)     ->		Optional[int]:

       '''simple docstring'''




       snake_case   :				Optional[Any]				 =   AlbertForQuestionAnswering(config=_a						)
       model.to(_a						)
       model.eval()
       snake_case   :				Tuple				 =   model(
           _a						,     attention_mask=_a						,     token_type_ids=_a						,     start_positions=_a						,     end_positions=_a						,     )
       self.parent.assertEqual(result.start_logits.shape						,     (self.batch_size, self.seq_length)						)
       self.parent.assertEqual(result.end_logits.shape						,     (self.batch_size, self.seq_length)						)







   def 			lowerCamelCase		(     self						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						)     ->		str:

       '''simple docstring'''




       snake_case   :				Tuple				 =   self.num_labels
       snake_case   :				Dict				 =   AlbertForSequenceClassification(_a						)
       model.to(_a						)
       model.eval()
       snake_case   :				List[Any]				 =   model(_a						,     attention_mask=_a						,     token_type_ids=_a						,     labels=_a						)
       self.parent.assertEqual(result.logits.shape						,     (self.batch_size, self.num_labels)						)







   def 			lowerCamelCase		(     self						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						)     ->		List[Any]:

       '''simple docstring'''




       snake_case   :				Optional[int]				 =   self.num_labels
       snake_case   :				Union[str, Any]				 =   AlbertForTokenClassification(config=_a						)
       model.to(_a						)
       model.eval()
       snake_case   :				Optional[int]				 =   model(_a						,     attention_mask=_a						,     token_type_ids=_a						,     labels=_a						)
       self.parent.assertEqual(result.logits.shape						,     (self.batch_size, self.seq_length, self.num_labels)						)







   def 			lowerCamelCase		(     self						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__						)     ->		Optional[int]:

       '''simple docstring'''




       snake_case   :				Dict				 =   self.num_choices
       snake_case   :				int				 =   AlbertForMultipleChoice(config=_a						)
       model.to(_a						)
       model.eval()
       snake_case   :				Union[str, Any]				 =   input_ids.unsqueeze(1						).expand(-1						,     self.num_choices						,     -1						).contiguous()
       snake_case   :				str				 =   token_type_ids.unsqueeze(1						).expand(-1						,     self.num_choices						,     -1						).contiguous()
       snake_case   :				Optional[Any]				 =   input_mask.unsqueeze(1						).expand(-1						,     self.num_choices						,     -1						).contiguous()
       snake_case   :				Tuple				 =   model(
           _a						,     attention_mask=_a						,     token_type_ids=_a						,     labels=_a						,     )
       self.parent.assertEqual(result.logits.shape						,     (self.batch_size, self.num_choices)						)







   def 			lowerCamelCase		(     self						)     ->		Union[str, Any]:

       '''simple docstring'''




       snake_case   :				List[str]				 =   self.prepare_config_and_inputs()
       (
           snake_case 
       )   :				Optional[int]				 =   config_and_inputs
       snake_case   :				List[Any]				 =   {'''input_ids''': input_ids, '''token_type_ids''': token_type_ids, '''attention_mask''': input_mask}
       return config, inputs_dict







@require_torch
class _lowerCAmelCase    (				__lowercase   ,							__lowercase   ,							unittest.TestCase     ):
   __UpperCAmelCase			:	Dict							  =  (
       (
           AlbertModel,
           AlbertForPreTraining,
           AlbertForMaskedLM,
           AlbertForMultipleChoice,
           AlbertForSequenceClassification,
           AlbertForTokenClassification,
           AlbertForQuestionAnswering,
       )
       if is_torch_available()
       else ()
   )
   __UpperCAmelCase			:	Optional[int]							  =  (
       {
           "feature-extraction": AlbertModel,
           "fill-mask": AlbertForMaskedLM,
           "question-answering": AlbertForQuestionAnswering,
           "text-classification": AlbertForSequenceClassification,
           "token-classification": AlbertForTokenClassification,
           "zero-shot": AlbertForSequenceClassification,
       }
       if is_torch_available()
       else {}
   )
   __UpperCAmelCase			:	Dict							  =  True







   def 			lowerCamelCase		(     self						,     UpperCamelCase__						,     UpperCamelCase__						,     UpperCamelCase__=False						)     ->		List[str]:

       '''simple docstring'''




       snake_case   :				int				 =   super()._prepare_for_class(_a						,     _a						,     return_labels=_a						)

       if return_labels:
           if model_class in get_values(_a						):
               snake_case   :				Any				 =   torch.zeros(
                   (self.model_tester.batch_size, self.model_tester.seq_length)						,     dtype=torch.long						,     device=_a						)
               snake_case   :				str				 =   torch.zeros(
                   self.model_tester.batch_size						,     dtype=torch.long						,     device=_a						)
       return inputs_dict







   def 			lowerCamelCase		(     self						)     ->		str:

       '''simple docstring'''




       snake_case   :				Tuple				 =   AlbertModelTester(self						)
       snake_case   :				int				 =   ConfigTester(self						,     config_class=_a						,     hidden_size=37						)







   def 			lowerCamelCase		(     self						)     ->		Dict:

       '''simple docstring'''




       self.config_tester.run_common_tests()







   def 			lowerCamelCase		(     self						)     ->		Any:

       '''simple docstring'''




       snake_case   :				Any				 =   self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_model(*_a						)







   def 			lowerCamelCase		(     self						)     ->		str:

       '''simple docstring'''




       snake_case   :				Union[str, Any]				 =   self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_pretraining(*_a						)







   def 			lowerCamelCase		(     self						)     ->		int:

       '''simple docstring'''




       snake_case   :				List[Any]				 =   self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_masked_lm(*_a						)







   def 			lowerCamelCase		(     self						)     ->		Optional[int]:

       '''simple docstring'''




       snake_case   :				List[Any]				 =   self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_multiple_choice(*_a						)







   def 			lowerCamelCase		(     self						)     ->		Union[str, Any]:

       '''simple docstring'''




       snake_case   :				int				 =   self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_question_answering(*_a						)







   def 			lowerCamelCase		(     self						)     ->		Union[str, Any]:

       '''simple docstring'''




       snake_case   :				Optional[Any]				 =   self.model_tester.prepare_config_and_inputs()
       self.model_tester.create_and_check_for_sequence_classification(*_a						)







   def 			lowerCamelCase		(     self						)     ->		Any:

       '''simple docstring'''




       snake_case   :				Optional[int]				 =   self.model_tester.prepare_config_and_inputs()
       for type in ["absolute", "relative_key", "relative_key_query"]:
           snake_case   :				Any				 =   type
           self.model_tester.create_and_check_model(*_a						)







   @slow
   def 			lowerCamelCase		(     self						)     ->		Dict:

       '''simple docstring'''




       for model_name in ALBERT_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
           snake_case   :				List[str]				 =   AlbertModel.from_pretrained(_a						)
           self.assertIsNotNone(_a						)







@require_torch
class _lowerCAmelCase    (				unittest.TestCase     ):







   @slow
   def 			lowerCamelCase		(     self						)     ->		int:

       '''simple docstring'''




       snake_case   :				Optional[int]				 =   AlbertModel.from_pretrained("albert-base-v2"						)
       snake_case   :				int				 =   torch.tensor([[0, 345, 232, 328, 740, 140, 1695, 69, 6078, 1588, 2]]						)
       snake_case   :				int				 =   torch.tensor([[0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]]						)
       with torch.no_grad():
           snake_case   :				List[str]				 =   model(_a						,     attention_mask=_a						)[0]
       snake_case   :				List[str]				 =   torch.Size((1, 11, 768)						)
       self.assertEqual(output.shape						,     _a						)
       snake_case   :				List[Any]				 =   torch.tensor(
           [[[-0.6513, 1.5035, -0.2766], [-0.6515, 1.5046, -0.2780], [-0.6512, 1.5049, -0.2784]]]						)

       self.assertTrue(torch.allclose(output[:, 1:4, 1:4]						,     _a						,     atol=1e-4						)						)









"""simple docstring"""



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 _lowerCAmelCase    (				snake_case_     ):
   __UpperCAmelCase			:	Tuple							  =  '''altclip_text_model'''







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

       '''simple docstring'''




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

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







class _lowerCAmelCase    (				snake_case_     ):
   __UpperCAmelCase			:	Tuple							  =  '''altclip_vision_model'''







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

       '''simple docstring'''




       super().__init__(**UpperCamelCase__						)

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







   @classmethod
   def 			lowerCamelCase		(     cls						,     UpperCamelCase__						,     **UpperCamelCase__						)     ->		"PretrainedConfig":

       '''simple docstring'''




       cls._set_token_in_kwargs(UpperCamelCase__						)

       snake_case ,snake_case   :				str				 =   cls.get_config_dict(UpperCamelCase__						,     **UpperCamelCase__						)

       # get the vision config dict if we are loading from AltCLIPConfig
       if config_dict.get("model_type"						) == "altclip":
           snake_case   :				Optional[Any]				 =   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 _lowerCAmelCase    (				snake_case_     ):
   __UpperCAmelCase			:	str							  =  '''altclip'''
   __UpperCAmelCase			:	Optional[Any]							  =  True







   def __init__(     self						,     UpperCamelCase__=None						,     UpperCamelCase__=None						,     UpperCamelCase__=768						,     UpperCamelCase__=2.6592						,     **UpperCamelCase__						)     ->		Any:

       '''simple docstring'''




       snake_case   :				List[str]				 =   kwargs.pop("text_config_dict"						,     UpperCamelCase__						)
       snake_case   :				Union[str, Any]				 =   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:
               snake_case   :				List[str]				 =   {}

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

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

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

       snake_case   :				Dict				 =   AltCLIPTextConfig(**UpperCamelCase__						)
       snake_case   :				Tuple				 =   AltCLIPVisionConfig(**UpperCamelCase__						)

       snake_case   :				int				 =   projection_dim
       snake_case   :				List[str]				 =   logit_scale_init_value
       snake_case   :				int				 =   1.0







   @classmethod
   def 			lowerCamelCase		(     cls						,     UpperCamelCase__						,     UpperCamelCase__						,     **UpperCamelCase__						)     ->		Union[str, Any]:

       '''simple docstring'''




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







   def 			lowerCamelCase		(     self						)     ->		Optional[Any]:

       '''simple docstring'''




       snake_case   :				Tuple				 =   copy.deepcopy(self.__dict__						)
       snake_case   :				Optional[int]				 =   self.text_config.to_dict()
       snake_case   :				str				 =   self.vision_config.to_dict()
       snake_case   :				Optional[int]				 =   self.__class__.model_type
       return output





