




"""simple docstring"""

import copy
import os
from typing import Union

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


_lowerCamelCase  :			Any        =       logging.get_logger(__name__)

_lowerCamelCase  :			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        lowercase      (    __UpperCAmelCase):
				__lowerCAmelCase    :    Optional[int]         =   """bridgetower_vision_model"""







				def __init__(							self   :					List[str]      ,     _lowerCamelCase   :					Union[str, Any]=7_68      ,     _lowerCamelCase   :					Optional[int]=12      ,     _lowerCamelCase   :					int=3      ,     _lowerCamelCase   :					int=16      ,     _lowerCamelCase   :					Dict=2_88      ,     _lowerCamelCase   :					List[str]=1      ,     _lowerCamelCase   :					Dict=1E-05      ,     _lowerCamelCase   :					Optional[Any]=False      ,     _lowerCamelCase   :					Union[str, Any]=True      ,     _lowerCamelCase   :					int=False      ,     **_lowerCamelCase   :					Any      ,     ):



					"""simple docstring"""

					super().__init__(**_lowerCamelCase       )
					A_  :				List[str]	   =		hidden_size
					A_  :				str	   =		num_hidden_layers
					A_  :				List[str]	   =		num_channels
					A_  :				Tuple	   =		patch_size
					A_  :				Optional[Any]	   =		image_size
					A_  :				int	   =		initializer_factor
					A_  :				Optional[Any]	   =		layer_norm_eps
					A_  :				Tuple	   =		stop_gradient
					A_  :				Dict	   =		share_layernorm
					A_  :				List[str]	   =		remove_last_layer







				@classmethod
				def 					a_  (							cls   :					Optional[int]      ,     _lowerCamelCase   :					Union[str, os.PathLike]      ,     **_lowerCamelCase   :					str       ):



					"""simple docstring"""

					A_   , A_  :				Any	   =		cls.get_config_dict(_lowerCamelCase      ,     **_lowerCamelCase       )

					if config_dict.get('''model_type'''       ) == "bridgetower":
						A_  :				List[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(_lowerCamelCase      ,     **_lowerCamelCase       )

class        lowercase      (    __UpperCAmelCase):
				__lowerCAmelCase    :    Any         =   """bridgetower_text_model"""







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



					"""simple docstring"""

					super().__init__(**_lowerCamelCase       )

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







				@classmethod
				def 					a_  (							cls   :					Tuple      ,     _lowerCamelCase   :					Union[str, os.PathLike]      ,     **_lowerCamelCase   :					List[Any]       ):



					"""simple docstring"""

					A_   , A_  :				int	   =		cls.get_config_dict(_lowerCamelCase      ,     **_lowerCamelCase       )

					if config_dict.get('''model_type'''       ) == "bridgetower":
						A_  :				Optional[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(_lowerCamelCase      ,     **_lowerCamelCase       )

class        lowercase      (    __UpperCAmelCase):
				__lowerCAmelCase    :    Any         =   """bridgetower"""







				def __init__(							self   :					Any      ,     _lowerCamelCase   :					Dict=True      ,     _lowerCamelCase   :					Optional[Any]="gelu"      ,     _lowerCamelCase   :					Dict=7_68      ,     _lowerCamelCase   :					Tuple=1      ,     _lowerCamelCase   :					Any=1E-05      ,     _lowerCamelCase   :					str=False      ,     _lowerCamelCase   :					List[str]="add"      ,     _lowerCamelCase   :					int=12      ,     _lowerCamelCase   :					List[Any]=6      ,     _lowerCamelCase   :					List[Any]=False      ,     _lowerCamelCase   :					Tuple=False      ,     _lowerCamelCase   :					Union[str, Any]=None      ,     _lowerCamelCase   :					List[Any]=None      ,     **_lowerCamelCase   :					Dict      ,     ):



					"""simple docstring"""

					A_  :				Any	   =		kwargs.pop('''text_config_dict'''      ,     _lowerCamelCase       )
					A_  :				Tuple	   =		kwargs.pop('''vision_config_dict'''      ,     _lowerCamelCase       )

					super().__init__(**_lowerCamelCase       )
					A_  :				str	   =		share_cross_modal_transformer_layers
					A_  :				List[Any]	   =		hidden_act
					A_  :				Optional[Any]	   =		hidden_size
					A_  :				int	   =		initializer_factor
					A_  :				List[Any]	   =		layer_norm_eps
					A_  :				List[str]	   =		share_link_tower_layers
					A_  :				Optional[int]	   =		link_tower_type
					A_  :				List[Any]	   =		num_attention_heads
					A_  :				Optional[int]	   =		num_hidden_layers
					A_  :				List[Any]	   =		tie_word_embeddings
					A_  :				int	   =		init_layernorm_from_vision_encoder

					if text_config is None:
						A_  :				List[str]	   =		{}
						logger.info('''`text_config` is `None`. Initializing the `BridgeTowerTextConfig` with default values.'''       )

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

					A_  :				str	   =		BridgeTowerTextConfig(**_lowerCamelCase       )
					A_  :				int	   =		BridgeTowerVisionConfig(**_lowerCamelCase       )







				@classmethod
				def 					a_  (							cls   :					Dict      ,     _lowerCamelCase   :					BridgeTowerTextConfig      ,     _lowerCamelCase   :					BridgeTowerVisionConfig      ,     **_lowerCamelCase   :					Optional[Any]       ):



					"""simple docstring"""

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







				def 					a_  (							self   :					Optional[Any]       ):



					"""simple docstring"""

					A_  :				Optional[Any]	   =		copy.deepcopy(self.__dict__       )
					A_  :				int	   =		self.text_config.to_dict()
					A_  :				Optional[Any]	   =		self.vision_config.to_dict()
					A_  :				Any	   =		self.__class__.model_type
					return output











"""simple docstring"""

from typing import TYPE_CHECKING

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


_lowerCamelCase  :			Optional[Any]        =       {
    'configuration_mask2former': [
        'MASK2FORMER_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'Mask2FormerConfig',
    ],
}

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

try:
		if not is_torch_available():
				raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
		pass
else:
		_lowerCamelCase  :			Tuple        =       [
		    '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

		_lowerCamelCase  :			Optional[Any]        =       _LazyModule(__name__, globals()['__file__'], _import_structure)





