



"""simple docstring"""

import copy
import os
from typing import Union

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


a_				   =					logging.get_logger(__name__)

a_				   =					{
    '''microsoft/git-base''': '''https://huggingface.co/microsoft/git-base/resolve/main/config.json''',
}







class    __lowercase     (					a__):







						"""simple docstring"""







						_A		:							int							       =		"""git_vision_model"""







						def __init__(self   ,		lowercase__=7_68   ,		lowercase__=30_72   ,		lowercase__=12   ,		lowercase__=12   ,		lowercase__=3   ,		lowercase__=2_24   ,		lowercase__=16   ,		lowercase__="quick_gelu"   ,		lowercase__=1e-5   ,		lowercase__=0.0   ,		lowercase__=0.02   ,		**lowercase__   ,		):
											super().__init__(**lowerCAmelCase__       )

											snake_case_					:		Tuple 					=					hidden_size
											snake_case_					:		List[Any] 					=					intermediate_size
											snake_case_					:		List[Any] 					=					num_hidden_layers
											snake_case_					:		Tuple 					=					num_attention_heads
											snake_case_					:		str 					=					num_channels
											snake_case_					:		Union[str, Any] 					=					patch_size
											snake_case_					:		List[Any] 					=					image_size
											snake_case_					:		Optional[int] 					=					initializer_range
											snake_case_					:		Tuple 					=					attention_dropout
											snake_case_					:		Union[str, Any] 					=					layer_norm_eps
											snake_case_					:		List[Any] 					=					hidden_act







						@classmethod
						def 						__UpperCamelCase							(cls   ,		lowercase__   ,		**lowercase__       ):
											cls._set_token_in_kwargs(lowerCAmelCase__       )

											snake_case_					:		List[str] 					=					cls.get_config_dict(lowerCAmelCase__   ,		**lowerCAmelCase__       )

											# get the vision config dict if we are loading from GITConfig
											if config_dict.get("""model_type"""       ) == "git":
																snake_case_					:		Dict 					=					config_dict["vision_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     (					a__):







						"""simple docstring"""







						_A		:							List[Any]							       =		"""git"""







						def __init__(self   ,		lowercase__=None   ,		lowercase__=3_05_22   ,		lowercase__=7_68   ,		lowercase__=6   ,		lowercase__=12   ,		lowercase__=30_72   ,		lowercase__="gelu"   ,		lowercase__=0.1   ,		lowercase__=0.1   ,		lowercase__=10_24   ,		lowercase__=0.02   ,		lowercase__=1e-12   ,		lowercase__=0   ,		lowercase__="absolute"   ,		lowercase__=True   ,		lowercase__=False   ,		lowercase__=1_01   ,		lowercase__=1_02   ,		lowercase__=None   ,		**lowercase__   ,		):
											super().__init__(bos_token_id=lowerCAmelCase__   ,		eos_token_id=lowerCAmelCase__   ,		pad_token_id=lowerCAmelCase__   ,		**lowerCAmelCase__       )

											if vision_config is None:
																snake_case_					:		List[str] 					=					{}
																logger.info("""vision_config is None. initializing the GitVisionConfig with default values."""       )

											snake_case_					:		Optional[int] 					=					GitVisionConfig(**lowerCAmelCase__       )
											snake_case_					:		str 					=					vocab_size
											snake_case_					:		Union[str, Any] 					=					hidden_size
											snake_case_					:		str 					=					num_hidden_layers
											snake_case_					:		List[str] 					=					num_attention_heads
											snake_case_					:		Any 					=					hidden_act
											snake_case_					:		Tuple 					=					intermediate_size
											snake_case_					:		List[Any] 					=					hidden_dropout_prob
											snake_case_					:		Tuple 					=					attention_probs_dropout_prob
											snake_case_					:		str 					=					max_position_embeddings
											snake_case_					:		int 					=					initializer_range
											snake_case_					:		Optional[int] 					=					layer_norm_eps
											snake_case_					:		int 					=					position_embedding_type
											snake_case_					:		Optional[Any] 					=					use_cache
											snake_case_					:		Any 					=					tie_word_embeddings
											snake_case_					:		List[Any] 					=					num_image_with_embedding

											snake_case_					:		int 					=					bos_token_id
											snake_case_					:		str 					=					eos_token_id







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









"""simple docstring"""

import copy

from ...configuration_utils import PretrainedConfig
from ...utils import logging
from ..auto.configuration_auto import CONFIG_MAPPING


a_			   =					logging.get_logger(__name__)







class    __lowercase     (					_UpperCAmelCase):







						"""simple docstring"""







						_A		:							Optional[int]							       =		"""upernet"""







						def __init__(self   ,		lowercase__=None   ,		lowercase__=5_12   ,		lowercase__=0.02   ,		lowercase__=[1, 2, 3, 6]   ,		lowercase__=True   ,		lowercase__=0.4   ,		lowercase__=3_84   ,		lowercase__=2_56   ,		lowercase__=1   ,		lowercase__=False   ,		lowercase__=2_55   ,		**lowercase__   ,		):
											super().__init__(**lowercase__       )

											if backbone_config is None:
																logger.info("""`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone."""       )
																snake_case_					:		List[Any] 					=					CONFIG_MAPPING["""resnet"""](out_features=["""stage1""", """stage2""", """stage3""", """stage4"""]       )
											elif isinstance(lowercase__   ,		lowercase__       ):
																snake_case_					:		Tuple 					=					backbone_config.get("""model_type"""       )
																snake_case_					:		List[str] 					=					CONFIG_MAPPING[backbone_model_type]
																snake_case_					:		List[Any] 					=					config_class.from_dict(lowercase__       )

											snake_case_					:		List[Any] 					=					backbone_config
											snake_case_					:		Optional[Any] 					=					hidden_size
											snake_case_					:		Any 					=					initializer_range
											snake_case_					:		str 					=					pool_scales
											snake_case_					:		Dict 					=					use_auxiliary_head
											snake_case_					:		str 					=					auxiliary_loss_weight
											snake_case_					:		List[str] 					=					auxiliary_in_channels
											snake_case_					:		Optional[Any] 					=					auxiliary_channels
											snake_case_					:		Any 					=					auxiliary_num_convs
											snake_case_					:		List[Any] 					=					auxiliary_concat_input
											snake_case_					:		List[str] 					=					loss_ignore_index







						def 						__UpperCamelCase							(self       ):
											snake_case_					:		Dict 					=					copy.deepcopy(self.__dict__       )
											snake_case_					:		Union[str, Any] 					=					self.backbone_config.to_dict()
											snake_case_					:		Any 					=					self.__class__.model_type
											return output




