
"""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        _UpperCAmelCase(       lowerCamelCase      ):
		lowercase__         = 'bridgetower_vision_model'



		def __init__(   self							,						__a=7_68							,						__a=12							,						__a=3							,						__a=16							,						__a=2_88							,						__a=1							,						__a=1e-05							,						__a=False							,						__a=True							,						__a=False							,						**__a							,						)			->			Union[str, Any]:






							'''simple docstring'''
							super().__init__(**__a)
							_UpperCamelCase									=    hidden_size
							_UpperCamelCase									=    num_hidden_layers
							_UpperCamelCase									=    num_channels
							_UpperCamelCase									=    patch_size
							_UpperCamelCase									=    image_size
							_UpperCamelCase									=    initializer_factor
							_UpperCamelCase									=    layer_norm_eps
							_UpperCamelCase									=    stop_gradient
							_UpperCamelCase									=    share_layernorm
							_UpperCamelCase									=    remove_last_layer




		@classmethod
		def 		UpperCAmelCase				(   cls							,						__a							,						**__a)			->			"PretrainedConfig":






							'''simple docstring'''
							_UpperCamelCase					,    _UpperCamelCase									=    cls.get_config_dict(__a							,						**__a)

							if config_dict.get('''model_type''') == "bridgetower":
												_UpperCamelCase									=    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        _UpperCAmelCase(       lowerCamelCase      ):
		lowercase__         = 'bridgetower_text_model'



		def __init__(   self							,						__a=5_02_65							,						__a=7_68							,						__a=12							,						__a=12							,						__a=1							,						__a=30_72							,						__a="gelu"							,						__a=0.1							,						__a=0.1							,						__a=5_14							,						__a=1							,						__a=1e-05							,						__a=1							,						__a=0							,						__a=2							,						__a="absolute"							,						__a=True							,						**__a							,						)			->			Any:






							'''simple docstring'''
							super().__init__(**__a)

							_UpperCamelCase									=    vocab_size
							_UpperCamelCase									=    hidden_size
							_UpperCamelCase									=    num_hidden_layers
							_UpperCamelCase									=    num_attention_heads
							_UpperCamelCase									=    hidden_act
							_UpperCamelCase									=    initializer_factor
							_UpperCamelCase									=    intermediate_size
							_UpperCamelCase									=    hidden_dropout_prob
							_UpperCamelCase									=    attention_probs_dropout_prob
							_UpperCamelCase									=    max_position_embeddings
							_UpperCamelCase									=    type_vocab_size
							_UpperCamelCase									=    layer_norm_eps
							_UpperCamelCase									=    position_embedding_type
							_UpperCamelCase									=    use_cache
							_UpperCamelCase									=    pad_token_id
							_UpperCamelCase									=    bos_token_id
							_UpperCamelCase									=    eos_token_id




		@classmethod
		def 		UpperCAmelCase				(   cls							,						__a							,						**__a)			->			"PretrainedConfig":






							'''simple docstring'''
							_UpperCamelCase					,    _UpperCamelCase									=    cls.get_config_dict(__a							,						**__a)

							if config_dict.get('''model_type''') == "bridgetower":
												_UpperCamelCase									=    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        _UpperCAmelCase(       lowerCamelCase      ):
		lowercase__         = 'bridgetower'



		def __init__(   self							,						__a=True							,						__a="gelu"							,						__a=7_68							,						__a=1							,						__a=1e-05							,						__a=False							,						__a="add"							,						__a=12							,						__a=6							,						__a=False							,						__a=False							,						__a=None							,						__a=None							,						**__a							,						)			->			Optional[int]:






							'''simple docstring'''
							# TODO: remove this once the Hub files are updated.
							_UpperCamelCase									=    kwargs.pop('''text_config_dict'''							,						__a)
							_UpperCamelCase									=    kwargs.pop('''vision_config_dict'''							,						__a)

							super().__init__(**__a)
							_UpperCamelCase									=    share_cross_modal_transformer_layers
							_UpperCamelCase									=    hidden_act
							_UpperCamelCase									=    hidden_size
							_UpperCamelCase									=    initializer_factor
							_UpperCamelCase									=    layer_norm_eps
							_UpperCamelCase									=    share_link_tower_layers
							_UpperCamelCase									=    link_tower_type
							_UpperCamelCase									=    num_attention_heads
							_UpperCamelCase									=    num_hidden_layers
							_UpperCamelCase									=    tie_word_embeddings
							_UpperCamelCase									=    init_layernorm_from_vision_encoder

							if text_config is None:
												_UpperCamelCase									=    {}
												logger.info('''`text_config` is `None`. Initializing the `BridgeTowerTextConfig` with default values.''')

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

							_UpperCamelCase									=    BridgeTowerTextConfig(**__a)
							_UpperCamelCase									=    BridgeTowerVisionConfig(**__a)



		@classmethod
		def 		UpperCAmelCase				(   cls							,						__a							,						__a							,						**__a)			->			str:






							'''simple docstring'''
							return cls(text_config=text_config.to_dict()							,						vision_config=vision_config.to_dict()							,						**__a)




		def 		UpperCAmelCase				(   self)			->			Any:






							'''simple docstring'''
							_UpperCamelCase									=    copy.deepcopy(self.__dict__)
							_UpperCamelCase									=    self.text_config.to_dict()
							_UpperCamelCase									=    self.vision_config.to_dict()
							_UpperCamelCase									=    self.__class__.model_type
							return output












'''simple docstring'''







import logging

from transformers.configuration_utils import PretrainedConfig


lowercase      :   int      =       logging.getLogger(__name__)







class 					_a (a__	):





     '''simple docstring'''



     lowerCAmelCase_  :     Union[str, Any]          =					"""masked_bert"""







     def __init__(				self							,__a=30_522							,__a=768							,__a=12							,__a=12							,__a=3_072							,__a="gelu"							,__a=0.1							,__a=0.1							,__a=512							,__a=2							,__a=0.02							,__a=1E-12							,__a=0							,__a="topK"							,__a="constant"							,__a=0.0							,**__a							,)      ->				List[str]:
          super().__init__(pad_token_id=__a							,**__a							)

          snake_case			:      Dict        =			vocab_size
          snake_case			:      Optional[Any]        =			hidden_size
          snake_case			:      Dict        =			num_hidden_layers
          snake_case			:      List[Any]        =			num_attention_heads
          snake_case			:      Dict        =			hidden_act
          snake_case			:      Any        =			intermediate_size
          snake_case			:      Optional[int]        =			hidden_dropout_prob
          snake_case			:      Optional[Any]        =			attention_probs_dropout_prob
          snake_case			:      List[Any]        =			max_position_embeddings
          snake_case			:      int        =			type_vocab_size
          snake_case			:      int        =			initializer_range
          snake_case			:      int        =			layer_norm_eps
          snake_case			:      Any        =			pruning_method
          snake_case			:      Union[str, Any]        =			mask_init
          snake_case			:      int        =			mask_scale



