






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 							__a							(  __A						):





		'''simple docstring'''



		UpperCAmelCase__      :				Tuple				    =						"""bridgetower_vision_model"""


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






		@classmethod
		def   __snake_case			(						cls ,    UpperCamelCase__ ,    **UpperCamelCase__       ):
						SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_   :	Optional[Any]													=   cls.get_config_dict(UpperCamelCase__ ,    **UpperCamelCase__       )

						if config_dict.get('model_type'       ) == "bridgetower":
										SCREAMING_SNAKE_CASE_   :	Dict													=   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 							__a							(  __A						):





		'''simple docstring'''



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


		def __init__(						self ,    UpperCamelCase__=50265 ,    UpperCamelCase__=768 ,    UpperCamelCase__=12 ,    UpperCamelCase__=12 ,    UpperCamelCase__=1 ,    UpperCamelCase__=3072 ,    UpperCamelCase__="gelu" ,    UpperCamelCase__=0.1 ,    UpperCamelCase__=0.1 ,    UpperCamelCase__=514 ,    UpperCamelCase__=1 ,    UpperCamelCase__=1E-05 ,    UpperCamelCase__=1 ,    UpperCamelCase__=0 ,    UpperCamelCase__=2 ,    UpperCamelCase__="absolute" ,    UpperCamelCase__=True ,    **UpperCamelCase__ ,    ):
						super().__init__(**UpperCamelCase__       )

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






		@classmethod
		def   __snake_case			(						cls ,    UpperCamelCase__ ,    **UpperCamelCase__       ):
						SCREAMING_SNAKE_CASE_							,       SCREAMING_SNAKE_CASE_   :	List[Any]													=   cls.get_config_dict(UpperCamelCase__ ,    **UpperCamelCase__       )

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






class 							__a							(  __A						):





		'''simple docstring'''



		UpperCAmelCase__      :				Dict				    =						"""bridgetower"""


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

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

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

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

						SCREAMING_SNAKE_CASE_   :	List[str]													=   BridgeTowerTextConfig(**UpperCamelCase__       )
						SCREAMING_SNAKE_CASE_   :	Any													=   BridgeTowerVisionConfig(**UpperCamelCase__       )


		@classmethod
		def   __snake_case			(						cls ,    UpperCamelCase__ ,    UpperCamelCase__ ,    **UpperCamelCase__       ):
						return cls(text_config=text_config.to_dict() ,    vision_config=vision_config.to_dict() ,    **UpperCamelCase__       )






		def   __snake_case			(						self       ):
						SCREAMING_SNAKE_CASE_   :	List[Any]													=   copy.deepcopy(self.__dict__       )
						SCREAMING_SNAKE_CASE_   :	List[str]													=   self.text_config.to_dict()
						SCREAMING_SNAKE_CASE_   :	Dict													=   self.vision_config.to_dict()
						SCREAMING_SNAKE_CASE_   :	List[Any]													=   self.__class__.model_type
						return output







import copy
from dataclasses import dataclass
from pathlib import Path
from typing import Dict, Optional, Union


@dataclass
class 							__a							:





		'''simple docstring'''



		UpperCAmelCase__      :				Optional[Union[str, Path]]				    =						None
		UpperCAmelCase__      :				bool				    =						False
		UpperCAmelCase__      :				bool				    =						False
		UpperCAmelCase__      :				bool				    =						False
		UpperCAmelCase__      :				Optional[Dict]				    =						None
		UpperCAmelCase__      :				Optional[str]				    =						None
		UpperCAmelCase__      :				bool				    =						False
		UpperCAmelCase__      :				bool				    =						False
		UpperCAmelCase__      :				bool				    =						False
		UpperCAmelCase__      :				bool				    =						True
		UpperCAmelCase__      :				Optional[int]				    =						None
		UpperCAmelCase__      :				int				    =						1
		UpperCAmelCase__      :				Optional[Union[str, bool]]				    =						None
		UpperCAmelCase__      :				bool				    =						False
		UpperCAmelCase__      :				Optional[Dict]				    =						None
		UpperCAmelCase__      :				Optional[str]				    =						None


		def   __snake_case			(						self       ):
						return self.__class__(**{k: copy.deepcopy(UpperCamelCase__       ) for k, v in self.__dict__.items()}       )