





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 			UpperCamelCase_		(  _lowerCamelCase					):
					lowerCAmelCase_							=	'''bridgetower_vision_model'''




					def __init__(		self				,						lowerCAmelCase_=768				,						lowerCAmelCase_=12				,						lowerCAmelCase_=3				,						lowerCAmelCase_=16				,						lowerCAmelCase_=288				,						lowerCAmelCase_=1				,						lowerCAmelCase_=1E-05				,						lowerCAmelCase_=False				,						lowerCAmelCase_=True				,						lowerCAmelCase_=False				,						**lowerCAmelCase_				,						)		->							Optional[Any]:
										super().__init__(**lowerCAmelCase_  )
										_snake_case									=				hidden_size
										_snake_case									=				num_hidden_layers
										_snake_case									=				num_channels
										_snake_case									=				patch_size
										_snake_case									=				image_size
										_snake_case									=				initializer_factor
										_snake_case									=				layer_norm_eps
										_snake_case									=				stop_gradient
										_snake_case									=				share_layernorm
										_snake_case									=				remove_last_layer






					@classmethod
					def 	lowerCAmelCase			(		cls				,						lowerCAmelCase_				,						**lowerCAmelCase_  )		->							"PretrainedConfig":
										_snake_case							,     _snake_case									=				cls.get_config_dict(lowerCAmelCase_				,						**lowerCAmelCase_  )

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





class 			UpperCamelCase_		(  _lowerCamelCase					):
					lowerCAmelCase_							=	'''bridgetower_text_model'''




					def __init__(		self				,						lowerCAmelCase_=5_0265				,						lowerCAmelCase_=768				,						lowerCAmelCase_=12				,						lowerCAmelCase_=12				,						lowerCAmelCase_=1				,						lowerCAmelCase_=3072				,						lowerCAmelCase_="gelu"				,						lowerCAmelCase_=0.1				,						lowerCAmelCase_=0.1				,						lowerCAmelCase_=514				,						lowerCAmelCase_=1				,						lowerCAmelCase_=1E-05				,						lowerCAmelCase_=1				,						lowerCAmelCase_=0				,						lowerCAmelCase_=2				,						lowerCAmelCase_="absolute"				,						lowerCAmelCase_=True				,						**lowerCAmelCase_				,						)		->							List[Any]:
										super().__init__(**lowerCAmelCase_  )

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






					@classmethod
					def 	lowerCAmelCase			(		cls				,						lowerCAmelCase_				,						**lowerCAmelCase_  )		->							"PretrainedConfig":
										_snake_case							,     _snake_case									=				cls.get_config_dict(lowerCAmelCase_				,						**lowerCAmelCase_  )

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





class 			UpperCamelCase_		(  _lowerCamelCase					):
					lowerCAmelCase_							=	'''bridgetower'''




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

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

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

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

										_snake_case									=				BridgeTowerTextConfig(**lowerCAmelCase_  )
										_snake_case									=				BridgeTowerVisionConfig(**lowerCAmelCase_  )




					@classmethod
					def 	lowerCAmelCase			(		cls				,						lowerCAmelCase_				,						lowerCAmelCase_				,						**lowerCAmelCase_  )		->							List[str]:
										return cls(text_config=text_config.to_dict()				,						vision_config=vision_config.to_dict()				,						**lowerCAmelCase_  )






					def 	lowerCAmelCase			(		self  )		->							Any:
										_snake_case									=				copy.deepcopy(self.__dict__  )
										_snake_case									=				self.text_config.to_dict()
										_snake_case									=				self.vision_config.to_dict()
										_snake_case									=				self.__class__.model_type
										return output










from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


UpperCAmelCase_      							=     {
    """configuration_bigbird_pegasus""": [
        """BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """BigBirdPegasusConfig""",
        """BigBirdPegasusOnnxConfig""",
    ],
}

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					UpperCAmelCase_      							=     [
					    """BIGBIRD_PEGASUS_PRETRAINED_MODEL_ARCHIVE_LIST""",
					    """BigBirdPegasusForCausalLM""",
					    """BigBirdPegasusForConditionalGeneration""",
					    """BigBirdPegasusForQuestionAnswering""",
					    """BigBirdPegasusForSequenceClassification""",
					    """BigBirdPegasusModel""",
					    """BigBirdPegasusPreTrainedModel""",
					]


if TYPE_CHECKING:
					from .configuration_bigbird_pegasus import (
					    BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP,
					    BigBirdPegasusConfig,
					    BigBirdPegasusOnnxConfig,
					)

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_bigbird_pegasus import (
										    BIGBIRD_PEGASUS_PRETRAINED_MODEL_ARCHIVE_LIST,
										    BigBirdPegasusForCausalLM,
										    BigBirdPegasusForConditionalGeneration,
										    BigBirdPegasusForQuestionAnswering,
										    BigBirdPegasusForSequenceClassification,
										    BigBirdPegasusModel,
										    BigBirdPegasusPreTrainedModel,
										)


else:
					import sys

					UpperCAmelCase_      							=     _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)



