
"""simple docstring"""






import copy
import os
from typing import Union

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


_lowercase							=				logging.get_logger(__name__)

_lowercase							=				{
    '''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'''







							_lowerCamelCase					:			int          =   """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  ,    )			->							List[str]:




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





							@classmethod
							def   SCREAMING_SNAKE_CASE						(     cls  ,    _lowerCamelCase  ,    **_lowerCamelCase       )			->							"PretrainedConfig":




										'''simple docstring'''
										__lowercase   ,					__lowercase       =       cls.get_config_dict(_lowerCamelCase  ,    **_lowerCamelCase       )

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



							'''simple docstring'''







							_lowerCamelCase					:			Union[str, Any]          =   """bridgetower_text_model"""
							def __init__(     self  ,    _lowerCamelCase=50_265  ,    _lowerCamelCase=768  ,    _lowerCamelCase=12  ,    _lowerCamelCase=12  ,    _lowerCamelCase=1  ,    _lowerCamelCase=3_072  ,    _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  ,    )			->							int:




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

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





							@classmethod
							def   SCREAMING_SNAKE_CASE						(     cls  ,    _lowerCamelCase  ,    **_lowerCamelCase       )			->							"PretrainedConfig":




										'''simple docstring'''
										__lowercase   ,					__lowercase       =       cls.get_config_dict(_lowerCamelCase  ,    **_lowerCamelCase       )

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



							'''simple docstring'''







							_lowerCamelCase					:			str          =   """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  ,    )			->							List[Any]:




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

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

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

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

										__lowercase       =       BridgeTowerTextConfig(**_lowerCamelCase       )
										__lowercase       =       BridgeTowerVisionConfig(**_lowerCamelCase       )
							@classmethod
							def   SCREAMING_SNAKE_CASE						(     cls  ,    _lowerCamelCase  ,    _lowerCamelCase  ,    **_lowerCamelCase       )			->							Union[str, Any]:




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





							def   SCREAMING_SNAKE_CASE						(     self       )			->							Dict:




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







"""simple docstring"""






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


_lowercase							=				{
    '''configuration_mask2former''': [
        '''MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP''',
        '''Mask2FormerConfig''',
    ],
}

try:
					if not is_vision_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					_lowercase							=				['''Mask2FormerImageProcessor''']

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					_lowercase							=				[
					    '''MASK2FORMER_PRETRAINED_MODEL_ARCHIVE_LIST''',
					    '''Mask2FormerForUniversalSegmentation''',
					    '''Mask2FormerModel''',
					    '''Mask2FormerPreTrainedModel''',
					]

if TYPE_CHECKING:
					from .configuration_maskaformer import MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, MaskaFormerConfig

					try:
										if not is_vision_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .image_processing_maskaformer import MaskaFormerImageProcessor

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_maskaformer import (
										    MASK2FORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
										    MaskaFormerForUniversalSegmentation,
										    MaskaFormerModel,
										    MaskaFormerPreTrainedModel,
										)


else:
					import sys

					_lowercase							=				_LazyModule(__name__, globals()['''__file__'''], _import_structure)





