


"""simple docstring"""



import copy
import os
from typing import Union

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


UpperCAmelCase      		=			logging.get_logger(__name__)

UpperCAmelCase      		=			{
    '''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 					__magic_name__		(			__UpperCAmelCase     ):
       __A			:      int        =   "bridgetower_vision_model"






       def __init__(   self  :    List[str]  ,     snake_case__  :    Dict=7_6_8  ,     snake_case__  :    Dict=1_2  ,     snake_case__  :    str=3  ,     snake_case__  :    List[Any]=1_6  ,     snake_case__  :    Tuple=2_8_8  ,     snake_case__  :    List[Any]=1  ,     snake_case__  :    Dict=1e-0_5  ,     snake_case__  :    Optional[Any]=False  ,     snake_case__  :    int=True  ,     snake_case__  :    List[Any]=False  ,     **snake_case__  :    Union[str, Any]  ,     ):

              '''simple docstring'''






              super().__init__(**snake_case__				)
              lowercase		:Optional[int]       							=				hidden_size
              lowercase		:Dict       							=				num_hidden_layers
              lowercase		:Dict       							=				num_channels
              lowercase		:List[str]       							=				patch_size
              lowercase		:Tuple       							=				image_size
              lowercase		:List[str]       							=				initializer_factor
              lowercase		:Tuple       							=				layer_norm_eps
              lowercase		:str       							=				stop_gradient
              lowercase		:Dict       							=				share_layernorm
              lowercase		:Dict       							=				remove_last_layer







       @classmethod
       def  __snake_case						(   cls  :    List[Any]  ,     snake_case__  :    Union[str, os.PathLike]  ,     **snake_case__  :    Union[str, Any]				):

              '''simple docstring'''






              lowercase		:Optional[Any]       							=				cls.get_config_dict(snake_case__  ,     **snake_case__				)

              if config_dict.get('''model_type'''				) == "bridgetower":
                     lowercase		:Optional[int]       							=				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(snake_case__  ,     **snake_case__				)







class 					__magic_name__		(			__UpperCAmelCase     ):
       __A			:      Optional[Any]        =   "bridgetower_text_model"






       def __init__(   self  :    Optional[Any]  ,     snake_case__  :    List[str]=5_0_2_6_5  ,     snake_case__  :    int=7_6_8  ,     snake_case__  :    Tuple=1_2  ,     snake_case__  :    Tuple=1_2  ,     snake_case__  :    List[Any]=1  ,     snake_case__  :    Dict=3_0_7_2  ,     snake_case__  :    List[str]="gelu"  ,     snake_case__  :    int=0.1  ,     snake_case__  :    Union[str, Any]=0.1  ,     snake_case__  :    Dict=5_1_4  ,     snake_case__  :    Union[str, Any]=1  ,     snake_case__  :    Optional[int]=1e-0_5  ,     snake_case__  :    List[Any]=1  ,     snake_case__  :    List[Any]=0  ,     snake_case__  :    List[Any]=2  ,     snake_case__  :    List[str]="absolute"  ,     snake_case__  :    Tuple=True  ,     **snake_case__  :    Any  ,     ):

              '''simple docstring'''






              super().__init__(**snake_case__				)

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







       @classmethod
       def  __snake_case						(   cls  :    Dict  ,     snake_case__  :    Union[str, os.PathLike]  ,     **snake_case__  :    List[str]				):

              '''simple docstring'''






              lowercase		:Dict       							=				cls.get_config_dict(snake_case__  ,     **snake_case__				)

              if config_dict.get('''model_type'''				) == "bridgetower":
                     lowercase		:List[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(snake_case__  ,     **snake_case__				)







class 					__magic_name__		(			__UpperCAmelCase     ):
       __A			:      List[str]        =   "bridgetower"






       def __init__(   self  :    List[str]  ,     snake_case__  :    Tuple=True  ,     snake_case__  :    List[Any]="gelu"  ,     snake_case__  :    Dict=7_6_8  ,     snake_case__  :    Union[str, Any]=1  ,     snake_case__  :    str=1e-0_5  ,     snake_case__  :    Any=False  ,     snake_case__  :    Any="add"  ,     snake_case__  :    List[str]=1_2  ,     snake_case__  :    int=6  ,     snake_case__  :    Optional[int]=False  ,     snake_case__  :    Union[str, Any]=False  ,     snake_case__  :    str=None  ,     snake_case__  :    str=None  ,     **snake_case__  :    List[str]  ,     ):

              '''simple docstring'''






              lowercase		:Dict       							=				kwargs.pop('''text_config_dict'''  ,     snake_case__				)
              lowercase		:Dict       							=				kwargs.pop('''vision_config_dict'''  ,     snake_case__				)

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

              if text_config is None:
                     lowercase		:Union[str, Any]       							=				{}
                     logger.info('''`text_config` is `None`. Initializing the `BridgeTowerTextConfig` with default values.'''				)

              if vision_config is None:
                     lowercase		:Tuple       							=				{}
                     logger.info('''`vision_config` is `None`. Initializing the `BridgeTowerVisionConfig` with default values.'''				)

              lowercase		:Optional[Any]       							=				BridgeTowerTextConfig(**snake_case__				)
              lowercase		:List[str]       							=				BridgeTowerVisionConfig(**snake_case__				)






       @classmethod
       def  __snake_case						(   cls  :    List[Any]  ,     snake_case__  :    BridgeTowerTextConfig  ,     snake_case__  :    BridgeTowerVisionConfig  ,     **snake_case__  :    List[str]				):

              '''simple docstring'''






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







       def  __snake_case						(   self  :    Optional[Any]				):

              '''simple docstring'''






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





"""simple docstring"""



from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_sentencepiece_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


UpperCAmelCase      		=			{
    '''configuration_xlm_roberta''': [
        '''XLM_ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''XLMRobertaConfig''',
        '''XLMRobertaOnnxConfig''',
    ],
}

try:
 if not is_sentencepiece_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 UpperCAmelCase      		=			['''XLMRobertaTokenizer''']

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

try:
 if not is_torch_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 UpperCAmelCase      		=			[
     '''XLM_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST''',
     '''XLMRobertaForCausalLM''',
     '''XLMRobertaForMaskedLM''',
     '''XLMRobertaForMultipleChoice''',
     '''XLMRobertaForQuestionAnswering''',
     '''XLMRobertaForSequenceClassification''',
     '''XLMRobertaForTokenClassification''',
     '''XLMRobertaModel''',
     '''XLMRobertaPreTrainedModel''',
 ]

try:
 if not is_tf_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 UpperCAmelCase      		=			[
     '''TF_XLM_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST''',
     '''TFXLMRobertaForCausalLM''',
     '''TFXLMRobertaForMaskedLM''',
     '''TFXLMRobertaForMultipleChoice''',
     '''TFXLMRobertaForQuestionAnswering''',
     '''TFXLMRobertaForSequenceClassification''',
     '''TFXLMRobertaForTokenClassification''',
     '''TFXLMRobertaModel''',
     '''TFXLMRobertaPreTrainedModel''',
 ]

try:
 if not is_flax_available():
  raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
 pass
else:
 UpperCAmelCase      		=			[
     '''FLAX_XLM_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST''',
     '''FlaxXLMRobertaForMaskedLM''',
     '''FlaxXLMRobertaForCausalLM''',
     '''FlaxXLMRobertaForMultipleChoice''',
     '''FlaxXLMRobertaForQuestionAnswering''',
     '''FlaxXLMRobertaForSequenceClassification''',
     '''FlaxXLMRobertaForTokenClassification''',
     '''FlaxXLMRobertaModel''',
     '''FlaxXLMRobertaPreTrainedModel''',
 ]

if TYPE_CHECKING:
 from .configuration_xlm_roberta import (
     XLM_ROBERTA_PRETRAINED_CONFIG_ARCHIVE_MAP,
     XLMRobertaConfig,
     XLMRobertaOnnxConfig,
 )

 try:
  if not is_sentencepiece_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .tokenization_xlm_roberta import XLMRobertaTokenizer

 try:
  if not is_tokenizers_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .tokenization_xlm_roberta_fast import XLMRobertaTokenizerFast

 try:
  if not is_torch_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_xlm_roberta import (
      XLM_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST,
      XLMRobertaForCausalLM,
      XLMRobertaForMaskedLM,
      XLMRobertaForMultipleChoice,
      XLMRobertaForQuestionAnswering,
      XLMRobertaForSequenceClassification,
      XLMRobertaForTokenClassification,
      XLMRobertaModel,
      XLMRobertaPreTrainedModel,
  )

 try:
  if not is_tf_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_tf_xlm_roberta import (
      TF_XLM_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST,
      TFXLMRobertaForCausalLM,
      TFXLMRobertaForMaskedLM,
      TFXLMRobertaForMultipleChoice,
      TFXLMRobertaForQuestionAnswering,
      TFXLMRobertaForSequenceClassification,
      TFXLMRobertaForTokenClassification,
      TFXLMRobertaModel,
      TFXLMRobertaPreTrainedModel,
  )

 try:
  if not is_flax_available():
   raise OptionalDependencyNotAvailable()
 except OptionalDependencyNotAvailable:
  pass
 else:
  from .modeling_flax_xlm_roberta import (
      FLAX_XLM_ROBERTA_PRETRAINED_MODEL_ARCHIVE_LIST,
      FlaxXLMRobertaForCausalLM,
      FlaxXLMRobertaForMaskedLM,
      FlaxXLMRobertaForMultipleChoice,
      FlaxXLMRobertaForQuestionAnswering,
      FlaxXLMRobertaForSequenceClassification,
      FlaxXLMRobertaForTokenClassification,
      FlaxXLMRobertaModel,
      FlaxXLMRobertaPreTrainedModel,
  )

else:
 import sys

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

