




"""simple docstring"""


from typing import TYPE_CHECKING

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


A_      			=       {
    '''configuration_mvp''': ['''MVP_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''MvpConfig''', '''MvpOnnxConfig'''],
    '''tokenization_mvp''': ['''MvpTokenizer'''],
}

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

try:
     if not is_torch_available():
          raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
     pass
else:
     A_      			=       [
         '''MVP_PRETRAINED_MODEL_ARCHIVE_LIST''',
         '''MvpForCausalLM''',
         '''MvpForConditionalGeneration''',
         '''MvpForQuestionAnswering''',
         '''MvpForSequenceClassification''',
         '''MvpModel''',
         '''MvpPreTrainedModel''',
     ]

if TYPE_CHECKING:
     from .configuration_mvp import MVP_PRETRAINED_CONFIG_ARCHIVE_MAP, MvpConfig, MvpOnnxConfig
     from .tokenization_mvp import MvpTokenizer

     try:
          if not is_tokenizers_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .tokenization_mvp_fast import MvpTokenizerFast

     try:
          if not is_torch_available():
               raise OptionalDependencyNotAvailable()
     except OptionalDependencyNotAvailable:
          pass
     else:
          from .modeling_mvp import (
              MVP_PRETRAINED_MODEL_ARCHIVE_LIST,
              MvpForCausalLM,
              MvpForConditionalGeneration,
              MvpForQuestionAnswering,
              MvpForSequenceClassification,
              MvpModel,
              MvpPreTrainedModel,
          )

else:
     import sys

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







"""simple docstring"""


import copy
import os
from typing import Union

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


A_      			=       logging.get_logger(__name__)

A_      			=       {
    '''BridgeTower/bridgetower-base''': '''https://huggingface.co/BridgeTower/bridgetower-base/blob/main/config.json''',
    '''BridgeTower/bridgetower-base-itm-mlm''': (
        '''https://huggingface.co/BridgeTower/bridgetower-base-itm-mlm/blob/main/config.json'''
    ),
}






class       lowercase(  __a				):







 '''simple docstring'''





 lowercase__				      =      "bridgetower_vision_model"


 def __init__(       self:	Tuple,   a_:	str=768,   a_:	Union[str, Any]=12,   a_:	List[str]=3,   a_:	Optional[int]=16,   a_:	List[Any]=288,   a_:	Optional[Any]=1,   a_:	Any=1E-05,   a_:	Dict=False,   a_:	Any=True,   a_:	int=False,   **a_:	int,   ):




   '''simple docstring'''



   super().__init__(**a_	)
   _snake_case							:	str			=						hidden_size
   _snake_case							:	int			=						num_hidden_layers
   _snake_case							:	Any			=						num_channels
   _snake_case							:	Union[str, Any]			=						patch_size
   _snake_case							:	Dict			=						image_size
   _snake_case							:	Optional[Any]			=						initializer_factor
   _snake_case							:	Any			=						layer_norm_eps
   _snake_case							:	int			=						stop_gradient
   _snake_case							:	Any			=						share_layernorm
   _snake_case							:	List[Any]			=						remove_last_layer


 @classmethod
 def 				UpperCamelCase_     (       cls:	Union[str, Any],   a_:	Union[str, os.PathLike],   **a_:	Optional[Any]	):




   '''simple docstring'''



   _snake_case	,      _snake_case							:	List[Any]			=						cls.get_config_dict(a_,   **a_	)

   if config_dict.get("""model_type"""	) == "bridgetower":
     _snake_case							:	str			=						config_dict["""text_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       lowercase(  __a				):







 '''simple docstring'''





 lowercase__				      =      "bridgetower_text_model"


 def __init__(       self:	str,   a_:	Dict=50_265,   a_:	List[Any]=768,   a_:	Union[str, Any]=12,   a_:	List[str]=12,   a_:	str=1,   a_:	Optional[Any]=3_072,   a_:	int="gelu",   a_:	int=0.1,   a_:	int=0.1,   a_:	Optional[int]=514,   a_:	Tuple=1,   a_:	Tuple=1E-05,   a_:	Optional[int]=1,   a_:	Union[str, Any]=0,   a_:	str=2,   a_:	Any="absolute",   a_:	List[Any]=True,   **a_:	Union[str, Any],   ):




   '''simple docstring'''



   super().__init__(**a_	)

   _snake_case							:	str			=						vocab_size
   _snake_case							:	Optional[int]			=						hidden_size
   _snake_case							:	Dict			=						num_hidden_layers
   _snake_case							:	Optional[int]			=						num_attention_heads
   _snake_case							:	Optional[int]			=						hidden_act
   _snake_case							:	List[Any]			=						initializer_factor
   _snake_case							:	Optional[int]			=						intermediate_size
   _snake_case							:	int			=						hidden_dropout_prob
   _snake_case							:	Tuple			=						attention_probs_dropout_prob
   _snake_case							:	List[str]			=						max_position_embeddings
   _snake_case							:	Optional[int]			=						type_vocab_size
   _snake_case							:	List[Any]			=						layer_norm_eps
   _snake_case							:	Dict			=						position_embedding_type
   _snake_case							:	Dict			=						use_cache
   _snake_case							:	int			=						pad_token_id
   _snake_case							:	Union[str, Any]			=						bos_token_id
   _snake_case							:	Union[str, Any]			=						eos_token_id


 @classmethod
 def 				UpperCamelCase_     (       cls:	str,   a_:	Union[str, os.PathLike],   **a_:	int	):




   '''simple docstring'''



   _snake_case	,      _snake_case							:	Optional[int]			=						cls.get_config_dict(a_,   **a_	)

   if config_dict.get("""model_type"""	) == "bridgetower":
     _snake_case							:	Union[str, Any]			=						config_dict["""text_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       lowercase(  __a				):







 '''simple docstring'''





 lowercase__				      =      "bridgetower"


 def __init__(       self:	int,   a_:	List[str]=True,   a_:	Any="gelu",   a_:	List[Any]=768,   a_:	int=1,   a_:	Optional[int]=1E-05,   a_:	Tuple=False,   a_:	Optional[Any]="add",   a_:	List[str]=12,   a_:	Union[str, Any]=6,   a_:	int=False,   a_:	Any=False,   a_:	Dict=None,   a_:	Any=None,   **a_:	str,   ):




   '''simple docstring'''



   _snake_case							:	str			=						kwargs.pop("""text_config_dict""",   a_	)
   _snake_case							:	Optional[Any]			=						kwargs.pop("""vision_config_dict""",   a_	)

   super().__init__(**a_	)
   _snake_case							:	str			=						share_cross_modal_transformer_layers
   _snake_case							:	Any			=						hidden_act
   _snake_case							:	Union[str, Any]			=						hidden_size
   _snake_case							:	Union[str, Any]			=						initializer_factor
   _snake_case							:	Dict			=						layer_norm_eps
   _snake_case							:	Dict			=						share_link_tower_layers
   _snake_case							:	Optional[int]			=						link_tower_type
   _snake_case							:	Any			=						num_attention_heads
   _snake_case							:	int			=						num_hidden_layers
   _snake_case							:	int			=						tie_word_embeddings
   _snake_case							:	Optional[Any]			=						init_layernorm_from_vision_encoder

   if text_config is None:
     _snake_case							:	Optional[Any]			=						{}
     logger.info("""`text_config` is `None`. Initializing the `BridgeTowerTextConfig` with default values."""	)

   if vision_config is None:
     _snake_case							:	str			=						{}
     logger.info("""`vision_config` is `None`. Initializing the `BridgeTowerVisionConfig` with default values."""	)

   _snake_case							:	Any			=						BridgeTowerTextConfig(**a_	)
   _snake_case							:	List[Any]			=						BridgeTowerVisionConfig(**a_	)


 @classmethod
 def 				UpperCamelCase_     (       cls:	Union[str, Any],   a_:	BridgeTowerTextConfig,   a_:	BridgeTowerVisionConfig,   **a_:	Optional[Any]	):




   '''simple docstring'''



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


 def 				UpperCamelCase_     (       self:	int	):




   '''simple docstring'''



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


