





'''simple docstring'''







import copy
import os
from typing import Union

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


_a   :					Tuple           =       logging.get_logger(__name__)

_a   :					str           =       {
    '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  ):
		a  :  Optional[Any]      ="""bridgetower_vision_model"""
		def __init__(    self,__SCREAMING_SNAKE_CASE=7_68,__SCREAMING_SNAKE_CASE=12,__SCREAMING_SNAKE_CASE=3,__SCREAMING_SNAKE_CASE=16,__SCREAMING_SNAKE_CASE=2_88,__SCREAMING_SNAKE_CASE=1,__SCREAMING_SNAKE_CASE=1e-05,__SCREAMING_SNAKE_CASE=False,__SCREAMING_SNAKE_CASE=True,__SCREAMING_SNAKE_CASE=False,**__SCREAMING_SNAKE_CASE,):



					'''simple docstring'''

					super().__init__(**SCREAMING_SNAKE_CASE_     )
					__lowerCAmelCase   		=							hidden_size
					__lowerCAmelCase   		=							num_hidden_layers
					__lowerCAmelCase   		=							num_channels
					__lowerCAmelCase   		=							patch_size
					__lowerCAmelCase   		=							image_size
					__lowerCAmelCase   		=							initializer_factor
					__lowerCAmelCase   		=							layer_norm_eps
					__lowerCAmelCase   		=							stop_gradient
					__lowerCAmelCase   		=							share_layernorm
					__lowerCAmelCase   		=							remove_last_layer







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



					'''simple docstring'''

					__lowerCAmelCase   		=							cls.get_config_dict(SCREAMING_SNAKE_CASE_,**SCREAMING_SNAKE_CASE_     )

					if config_dict.get("""model_type"""     ) == "bridgetower":
								__lowerCAmelCase   		=							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(SCREAMING_SNAKE_CASE_,**SCREAMING_SNAKE_CASE_     )





class        _UpperCAmelCase				(		_lowerCAmelCase  ):
		a  :  Tuple      ="""bridgetower_text_model"""
		def __init__(    self,__SCREAMING_SNAKE_CASE=5_02_65,__SCREAMING_SNAKE_CASE=7_68,__SCREAMING_SNAKE_CASE=12,__SCREAMING_SNAKE_CASE=12,__SCREAMING_SNAKE_CASE=1,__SCREAMING_SNAKE_CASE=30_72,__SCREAMING_SNAKE_CASE="gelu",__SCREAMING_SNAKE_CASE=0.1,__SCREAMING_SNAKE_CASE=0.1,__SCREAMING_SNAKE_CASE=5_14,__SCREAMING_SNAKE_CASE=1,__SCREAMING_SNAKE_CASE=1e-05,__SCREAMING_SNAKE_CASE=1,__SCREAMING_SNAKE_CASE=0,__SCREAMING_SNAKE_CASE=2,__SCREAMING_SNAKE_CASE="absolute",__SCREAMING_SNAKE_CASE=True,**__SCREAMING_SNAKE_CASE,):



					'''simple docstring'''

					super().__init__(**SCREAMING_SNAKE_CASE_     )

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







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



					'''simple docstring'''

					__lowerCAmelCase   		=							cls.get_config_dict(SCREAMING_SNAKE_CASE_,**SCREAMING_SNAKE_CASE_     )

					if config_dict.get("""model_type"""     ) == "bridgetower":
								__lowerCAmelCase   		=							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(SCREAMING_SNAKE_CASE_,**SCREAMING_SNAKE_CASE_     )





class        _UpperCAmelCase				(		_lowerCAmelCase  ):
		a  :  Dict      ="""bridgetower"""
		def __init__(    self,__SCREAMING_SNAKE_CASE=True,__SCREAMING_SNAKE_CASE="gelu",__SCREAMING_SNAKE_CASE=7_68,__SCREAMING_SNAKE_CASE=1,__SCREAMING_SNAKE_CASE=1e-05,__SCREAMING_SNAKE_CASE=False,__SCREAMING_SNAKE_CASE="add",__SCREAMING_SNAKE_CASE=12,__SCREAMING_SNAKE_CASE=6,__SCREAMING_SNAKE_CASE=False,__SCREAMING_SNAKE_CASE=False,__SCREAMING_SNAKE_CASE=None,__SCREAMING_SNAKE_CASE=None,**__SCREAMING_SNAKE_CASE,):



					'''simple docstring'''

					__lowerCAmelCase   		=							kwargs.pop("""text_config_dict""",SCREAMING_SNAKE_CASE_     )
					__lowerCAmelCase   		=							kwargs.pop("""vision_config_dict""",SCREAMING_SNAKE_CASE_     )

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

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

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

					__lowerCAmelCase   		=							BridgeTowerTextConfig(**SCREAMING_SNAKE_CASE_     )
					__lowerCAmelCase   		=							BridgeTowerVisionConfig(**SCREAMING_SNAKE_CASE_     )
		@classmethod
		def     lowerCamelCase__     (    cls,__SCREAMING_SNAKE_CASE,__SCREAMING_SNAKE_CASE,**__SCREAMING_SNAKE_CASE     ):



					'''simple docstring'''

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







		def     lowerCamelCase__     (    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






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


a      :  List[Any]			     =			logging.get_logger(__name__)







class 				_a				(   _lowerCAmelCase					):
			A      		=	'''timm_backbone'''

			def __init__(self,   SCREAMING_SNAKE_CASE_=None,   SCREAMING_SNAKE_CASE_=3,   SCREAMING_SNAKE_CASE_=True,   SCREAMING_SNAKE_CASE_=True,   SCREAMING_SNAKE_CASE_=None,   **SCREAMING_SNAKE_CASE_,   )       ->   Tuple:
						super().__init__(**SCREAMING_SNAKE_CASE_					)
						UpperCAmelCase_:		Dict							      =     backbone
						UpperCAmelCase_:		Optional[Any]							      =     num_channels
						UpperCAmelCase_:		Optional[Any]							      =     features_only
						UpperCAmelCase_:		Any							      =     use_pretrained_backbone
						UpperCAmelCase_:		List[str]							      =     True
						UpperCAmelCase_:		Union[str, Any]							      =     out_indices if out_indices is not None else (-1,)






