




import copy
import os
from typing import Union

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


__SCREAMING_SNAKE_CASE 						=logging.get_logger(__name__)

__SCREAMING_SNAKE_CASE 						={
    """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__						(  __A):
				'''simple docstring'''







				SCREAMING_SNAKE_CASE__					:							Tuple	      =					"""bridgetower_vision_model"""


				def __init__(							self:   Dict		,					_lowerCamelCase:   Dict=7_68		,					_lowerCamelCase:   int=12		,					_lowerCamelCase:   int=3		,					_lowerCamelCase:   List[Any]=16		,					_lowerCamelCase:   Tuple=2_88		,					_lowerCamelCase:   List[Any]=1		,					_lowerCamelCase:   Optional[Any]=1E-05		,					_lowerCamelCase:   Any=False		,					_lowerCamelCase:   Optional[int]=True		,					_lowerCamelCase:   Dict=False		,					**_lowerCamelCase:   Union[str, Any]		,					):
											super().__init__(**UpperCamelCase__		)
											SCREAMING_SNAKE_CASE_   	=    hidden_size
											SCREAMING_SNAKE_CASE_   	=    num_hidden_layers
											SCREAMING_SNAKE_CASE_   	=    num_channels
											SCREAMING_SNAKE_CASE_   	=    patch_size
											SCREAMING_SNAKE_CASE_   	=    image_size
											SCREAMING_SNAKE_CASE_   	=    initializer_factor
											SCREAMING_SNAKE_CASE_   	=    layer_norm_eps
											SCREAMING_SNAKE_CASE_   	=    stop_gradient
											SCREAMING_SNAKE_CASE_   	=    share_layernorm
											SCREAMING_SNAKE_CASE_   	=    remove_last_layer





				@classmethod
				def     _A							(							cls:   List[str]		,					_lowerCamelCase:   int		,					**_lowerCamelCase:   Optional[Any]		):
											SCREAMING_SNAKE_CASE_   	=    cls.get_config_dict(UpperCamelCase__		,					**UpperCamelCase__		)

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







class  __magic_name__						(  __A):
				'''simple docstring'''







				SCREAMING_SNAKE_CASE__					:							Optional[Any]	      =					"""bridgetower_text_model"""


				def __init__(							self:   Dict		,					_lowerCamelCase:   Tuple=5_02_65		,					_lowerCamelCase:   Tuple=7_68		,					_lowerCamelCase:   Optional[int]=12		,					_lowerCamelCase:   str=12		,					_lowerCamelCase:   Optional[int]=1		,					_lowerCamelCase:   Dict=30_72		,					_lowerCamelCase:   int="gelu"		,					_lowerCamelCase:   List[str]=0.1		,					_lowerCamelCase:   int=0.1		,					_lowerCamelCase:   Tuple=5_14		,					_lowerCamelCase:   Tuple=1		,					_lowerCamelCase:   int=1E-05		,					_lowerCamelCase:   int=1		,					_lowerCamelCase:   str=0		,					_lowerCamelCase:   Optional[int]=2		,					_lowerCamelCase:   Optional[Any]="absolute"		,					_lowerCamelCase:   Dict=True		,					**_lowerCamelCase:   List[Any]		,					):
											super().__init__(**UpperCamelCase__		)

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





				@classmethod
				def     _A							(							cls:   Optional[Any]		,					_lowerCamelCase:   List[Any]		,					**_lowerCamelCase:   int		):
											SCREAMING_SNAKE_CASE_   	=    cls.get_config_dict(UpperCamelCase__		,					**UpperCamelCase__		)

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







class  __magic_name__						(  __A):
				'''simple docstring'''







				SCREAMING_SNAKE_CASE__					:							Dict	      =					"""bridgetower"""


				def __init__(							self:   Tuple		,					_lowerCamelCase:   Union[str, Any]=True		,					_lowerCamelCase:   Union[str, Any]="gelu"		,					_lowerCamelCase:   List[Any]=7_68		,					_lowerCamelCase:   Tuple=1		,					_lowerCamelCase:   Union[str, Any]=1E-05		,					_lowerCamelCase:   Dict=False		,					_lowerCamelCase:   Tuple="add"		,					_lowerCamelCase:   List[Any]=12		,					_lowerCamelCase:   List[str]=6		,					_lowerCamelCase:   Dict=False		,					_lowerCamelCase:   List[Any]=False		,					_lowerCamelCase:   List[str]=None		,					_lowerCamelCase:   int=None		,					**_lowerCamelCase:   Optional[Any]		,					):
											# TODO: remove this once the Hub files are updated.
											SCREAMING_SNAKE_CASE_   	=    kwargs.pop('''text_config_dict'''		,					UpperCamelCase__		)
											SCREAMING_SNAKE_CASE_   	=    kwargs.pop('''vision_config_dict'''		,					UpperCamelCase__		)

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

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

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

											SCREAMING_SNAKE_CASE_   	=    BridgeTowerTextConfig(**UpperCamelCase__		)
											SCREAMING_SNAKE_CASE_   	=    BridgeTowerVisionConfig(**UpperCamelCase__		)


				@classmethod
				def     _A							(							cls:   Union[str, Any]		,					_lowerCamelCase:   Optional[int]		,					_lowerCamelCase:   str		,					**_lowerCamelCase:   Union[str, Any]		):
											return cls(text_config=text_config.to_dict()		,					vision_config=vision_config.to_dict()		,					**UpperCamelCase__		)





				def     _A							(							self:   Tuple		):
											SCREAMING_SNAKE_CASE_   	=    copy.deepcopy(self.__dict__		)
											SCREAMING_SNAKE_CASE_   	=    self.text_config.to_dict()
											SCREAMING_SNAKE_CASE_   	=    self.vision_config.to_dict()
											SCREAMING_SNAKE_CASE_   	=    self.__class__.model_type
											return output








from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__SCREAMING_SNAKE_CASE 						={
    """configuration_xlm_roberta_xl""": [
        """XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """XLMRobertaXLConfig""",
        """XLMRobertaXLOnnxConfig""",
    ],
}

try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			__SCREAMING_SNAKE_CASE 						=[
			    """XLM_ROBERTA_XL_PRETRAINED_MODEL_ARCHIVE_LIST""",
			    """XLMRobertaXLForCausalLM""",
			    """XLMRobertaXLForMaskedLM""",
			    """XLMRobertaXLForMultipleChoice""",
			    """XLMRobertaXLForQuestionAnswering""",
			    """XLMRobertaXLForSequenceClassification""",
			    """XLMRobertaXLForTokenClassification""",
			    """XLMRobertaXLModel""",
			    """XLMRobertaXLPreTrainedModel""",
			]

if TYPE_CHECKING:
			from .configuration_xlm_roberta_xl import (
			    XLM_ROBERTA_XL_PRETRAINED_CONFIG_ARCHIVE_MAP,
			    XLMRobertaXLConfig,
			    XLMRobertaXLOnnxConfig,
			)

			try:
						if not is_torch_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_xlm_roberta_xl import (
						    XLM_ROBERTA_XL_PRETRAINED_MODEL_ARCHIVE_LIST,
						    XLMRobertaXLForCausalLM,
						    XLMRobertaXLForMaskedLM,
						    XLMRobertaXLForMultipleChoice,
						    XLMRobertaXLForQuestionAnswering,
						    XLMRobertaXLForSequenceClassification,
						    XLMRobertaXLForTokenClassification,
						    XLMRobertaXLModel,
						    XLMRobertaXLPreTrainedModel,
						)

else:
			import sys

			__SCREAMING_SNAKE_CASE 						=_LazyModule(__name__, globals()["""__file__"""], _import_structure)


