import copy
import os
from typing import Union

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


_lowerCamelCase					:   str							=		logging.get_logger(__name__)

_lowerCamelCase					:   List[Any]							=		{
    '''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    (     __A     ):
							lowercase__						:       Tuple								=							"""bridgetower_vision_model"""




							def __init__(						self   :					Union[str, Any]	,							_UpperCamelCase   :					List[str]=768	,							_UpperCamelCase   :					List[str]=12	,							_UpperCamelCase   :					Optional[int]=3	,							_UpperCamelCase   :					List[Any]=16	,							_UpperCamelCase   :					List[Any]=288	,							_UpperCamelCase   :					str=1	,							_UpperCamelCase   :					int=1e-05	,							_UpperCamelCase   :					Optional[Any]=False	,							_UpperCamelCase   :					Union[str, Any]=True	,							_UpperCamelCase   :					Dict=False	,							**_UpperCamelCase   :					int	,							)					->				List[str]:



												'''simple docstring'''

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





							@classmethod
							def 	__snake_case(						cls   :					str	,							_UpperCamelCase   :					Optional[int]	,							**_UpperCamelCase   :					List[Any]      )					->				Union[str, Any]:



												'''simple docstring'''

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

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



class 						lowercase    (     __A     ):
							lowercase__						:       Optional[Any]								=							"""bridgetower_text_model"""




							def __init__(						self   :					str	,							_UpperCamelCase   :					List[str]=50_265	,							_UpperCamelCase   :					Optional[int]=768	,							_UpperCamelCase   :					Union[str, Any]=12	,							_UpperCamelCase   :					int=12	,							_UpperCamelCase   :					Optional[Any]=1	,							_UpperCamelCase   :					Optional[Any]=3_072	,							_UpperCamelCase   :					Any="gelu"	,							_UpperCamelCase   :					Tuple=0.1	,							_UpperCamelCase   :					Optional[int]=0.1	,							_UpperCamelCase   :					int=514	,							_UpperCamelCase   :					Optional[int]=1	,							_UpperCamelCase   :					Optional[Any]=1e-05	,							_UpperCamelCase   :					str=1	,							_UpperCamelCase   :					Dict=0	,							_UpperCamelCase   :					Dict=2	,							_UpperCamelCase   :					str="absolute"	,							_UpperCamelCase   :					int=True	,							**_UpperCamelCase   :					Union[str, Any]	,							)					->				Optional[Any]:



												'''simple docstring'''

												super().__init__(**UpperCamelCase__      )

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





							@classmethod
							def 	__snake_case(						cls   :					Dict	,							_UpperCamelCase   :					Tuple	,							**_UpperCamelCase   :					List[Any]      )					->				Union[str, Any]:



												'''simple docstring'''

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

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



class 						lowercase    (     __A     ):
							lowercase__						:       Dict								=							"""bridgetower"""




							def __init__(						self   :					Dict	,							_UpperCamelCase   :					Optional[Any]=True	,							_UpperCamelCase   :					Dict="gelu"	,							_UpperCamelCase   :					List[str]=768	,							_UpperCamelCase   :					List[str]=1	,							_UpperCamelCase   :					Dict=1e-05	,							_UpperCamelCase   :					Optional[Any]=False	,							_UpperCamelCase   :					str="add"	,							_UpperCamelCase   :					Optional[int]=12	,							_UpperCamelCase   :					Optional[Any]=6	,							_UpperCamelCase   :					Tuple=False	,							_UpperCamelCase   :					Union[str, Any]=False	,							_UpperCamelCase   :					List[Any]=None	,							_UpperCamelCase   :					Optional[int]=None	,							**_UpperCamelCase   :					Tuple	,							)					->				str:



												'''simple docstring'''

												SCREAMING_SNAKE_CASE    			=       kwargs.pop("text_config_dict"	,							UpperCamelCase__      )
												SCREAMING_SNAKE_CASE    			=       kwargs.pop("vision_config_dict"	,							UpperCamelCase__      )

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

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

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

												SCREAMING_SNAKE_CASE    			=       BridgeTowerTextConfig(**UpperCamelCase__      )
												SCREAMING_SNAKE_CASE    			=       BridgeTowerVisionConfig(**UpperCamelCase__      )




							@classmethod
							def 	__snake_case(						cls   :					Tuple	,							_UpperCamelCase   :					str	,							_UpperCamelCase   :					List[str]	,							**_UpperCamelCase   :					Any      )					->				int:



												'''simple docstring'''

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





							def 	__snake_case(						self   :					List[str]      )					->				int:



												'''simple docstring'''

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





# coding=utf-8
# Copyright 2023 The HuggingFace Inc. team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# this script dumps information about the environment

import os
import platform
import sys


_lowerCamelCase					:   List[Any]							=		'''3'''

print('''Python version:''', sys.version)

print('''OS platform:''', platform.platform())
print('''OS architecture:''', platform.machine())

try:
							import torch

							print('''Torch version:''', torch.__version__)
							print('''Cuda available:''', torch.cuda.is_available())
							print('''Cuda version:''', torch.version.cuda)
							print('''CuDNN version:''', torch.backends.cudnn.version())
							print('''Number of GPUs available:''', torch.cuda.device_count())
except ImportError:
							print('''Torch version:''', None)

try:
							import transformers

							print('''transformers version:''', transformers.__version__)
except ImportError:
							print('''transformers version:''', None)




