




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		(  __UpperCAmelCase     ):
		__snake_case									=   '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__,	):







								"""simple docstring"""



								super().__init__(**UpperCamelCase__   )
								lowerCAmelCase_      			=  hidden_size
								lowerCAmelCase_      			=  num_hidden_layers
								lowerCAmelCase_      			=  num_channels
								lowerCAmelCase_      			=  patch_size
								lowerCAmelCase_      			=  image_size
								lowerCAmelCase_      			=  initializer_factor
								lowerCAmelCase_      			=  layer_norm_eps
								lowerCAmelCase_      			=  stop_gradient
								lowerCAmelCase_      			=  share_layernorm
								lowerCAmelCase_      			=  remove_last_layer







		@classmethod
		def        SCREAMING_SNAKE_CASE__			(     cls,	UpperCamelCase__,	**UpperCamelCase__   ):







								"""simple docstring"""



								lowerCAmelCase_			,					lowerCAmelCase_      			=  cls.get_config_dict(UpperCamelCase__,	**UpperCamelCase__   )

								if config_dict.get('''model_type'''   ) == "bridgetower":
														lowerCAmelCase_      			=  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		(  __UpperCAmelCase     ):
		__snake_case									=   'bridgetower_text_model'



		def __init__(     self,	UpperCamelCase__=5_0265,	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__,	):







								"""simple docstring"""



								super().__init__(**UpperCamelCase__   )

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







		@classmethod
		def        SCREAMING_SNAKE_CASE__			(     cls,	UpperCamelCase__,	**UpperCamelCase__   ):







								"""simple docstring"""



								lowerCAmelCase_			,					lowerCAmelCase_      			=  cls.get_config_dict(UpperCamelCase__,	**UpperCamelCase__   )

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







								"""simple docstring"""



								lowerCAmelCase_      			=  kwargs.pop('''text_config_dict''',	UpperCamelCase__   )
								lowerCAmelCase_      			=  kwargs.pop('''vision_config_dict''',	UpperCamelCase__   )

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

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

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

								lowerCAmelCase_      			=  BridgeTowerTextConfig(**UpperCamelCase__   )
								lowerCAmelCase_      			=  BridgeTowerVisionConfig(**UpperCamelCase__   )



		@classmethod
		def        SCREAMING_SNAKE_CASE__			(     cls,	UpperCamelCase__,	UpperCamelCase__,	**UpperCamelCase__   ):







								"""simple docstring"""



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







		def        SCREAMING_SNAKE_CASE__			(     self   ):







								"""simple docstring"""



								lowerCAmelCase_      			=  copy.deepcopy(self.__dict__   )
								lowerCAmelCase_      			=  self.text_config.to_dict()
								lowerCAmelCase_      			=  self.vision_config.to_dict()
								lowerCAmelCase_      			=  self.__class__.model_type
								return output










import importlib
import os
from dataclasses import dataclass
from enum import Enum
from typing import Any, Dict, Optional, Union

import torch

from ..utils import BaseOutput


_A     =			'''scheduler_config.json'''


class  A		(  __UpperCAmelCase     ):
		__snake_case									=   1
		__snake_case									=   2
		__snake_case									=   3
		__snake_case									=   4
		__snake_case									=   5
		__snake_case									=   6
		__snake_case									=   7
		__snake_case									=   8
		__snake_case									=   9
		__snake_case									=   10
		__snake_case									=   11
		__snake_case									=   12
		__snake_case									=   13
		__snake_case									=   14







@dataclass
class  A		(  __UpperCAmelCase     ):
		__snake_case									=   42







class  A		:
		__snake_case									=   SCHEDULER_CONFIG_NAME
		__snake_case									=   []
		__snake_case									=   True



		@classmethod
		def        SCREAMING_SNAKE_CASE__			(     cls,	UpperCamelCase__ = None,	UpperCamelCase__ = None,	UpperCamelCase__=False,	**UpperCamelCase__,	):







								"""simple docstring"""



								lowerCAmelCase_			,					lowerCAmelCase_			,					lowerCAmelCase_      			=  cls.load_config(
								    pretrained_model_name_or_path=UpperCamelCase__,	subfolder=UpperCamelCase__,	return_unused_kwargs=UpperCamelCase__,	return_commit_hash=UpperCamelCase__,	**UpperCamelCase__,	)
								return cls.from_config(UpperCamelCase__,	return_unused_kwargs=UpperCamelCase__,	**UpperCamelCase__   )



		def        SCREAMING_SNAKE_CASE__			(     self,	UpperCamelCase__,	UpperCamelCase__ = False,	**UpperCamelCase__   ):







								"""simple docstring"""



								self.save_config(save_directory=UpperCamelCase__,	push_to_hub=UpperCamelCase__,	**UpperCamelCase__   )



		@property
		def        SCREAMING_SNAKE_CASE__			(     self   ):







								"""simple docstring"""



								return self._get_compatibles()







		@classmethod
		def        SCREAMING_SNAKE_CASE__			(     cls   ):







								"""simple docstring"""



								lowerCAmelCase_      			=  list(set([cls.__name__] + cls._compatibles   )   )
								lowerCAmelCase_      			=  importlib.import_module(__name__.split('''.'''   )[0]   )
								lowerCAmelCase_      			=  [
								    getattr(UpperCamelCase__,	UpperCamelCase__   ) for c in compatible_classes_str if hasattr(UpperCamelCase__,	UpperCamelCase__   )
								]
								return compatible_classes




