


'''simple docstring'''

import copy
import os
from typing import Union

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


lowerCAmelCase				:List[Any]        =      logging.get_logger(__name__)

lowerCAmelCase				:str        =      {
    '''microsoft/git-base''': '''https://huggingface.co/microsoft/git-base/resolve/main/config.json''',
}
class _lowerCamelCase	(						lowercase__							):



		'''simple docstring'''







		A_     :      Union[str, Any]				   =    """git_vision_model"""







		def __init__( self		:						Optional[Any]  ,					_A		:						Dict=768  ,					_A		:						List[str]=3072  ,					_A		:						str=12  ,					_A		:						Dict=12  ,					_A		:						Any=3  ,					_A		:						Optional[int]=224  ,					_A		:						int=16  ,					_A		:						Any="quick_gelu"  ,					_A		:						Union[str, Any]=1E-5  ,					_A		:						Any=0.0  ,					_A		:						Optional[Any]=0.02  ,					**_A		:						Union[str, Any]  ,					)  ->			Union[str, Any]:
			super().__init__(**_A      )

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







		@classmethod
		def        __lowerCAmelCase		( cls		:						str  ,					_A		:						Union[str, os.PathLike]  ,					**_A		:						Optional[int]      )  ->			"PretrainedConfig":
			cls._set_token_in_kwargs(_A      )

			__magic_name__     ,    __magic_name__	:   Optional[Any]					     =					cls.get_config_dict(_A  ,					**_A      )

			# get the vision config dict if we are loading from GITConfig
			if config_dict.get('model_type'      ) == "git":
				__magic_name__	:   Union[str, Any]					     =					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(_A  ,					**_A      )







class _lowerCamelCase	(						lowercase__							):



		'''simple docstring'''







		A_     :      List[str]				   =    """git"""







		def __init__( self		:						Optional[Any]  ,					_A		:						Tuple=None  ,					_A		:						str=30522  ,					_A		:						List[Any]=768  ,					_A		:						Optional[Any]=6  ,					_A		:						List[str]=12  ,					_A		:						List[Any]=3072  ,					_A		:						List[str]="gelu"  ,					_A		:						Dict=0.1  ,					_A		:						str=0.1  ,					_A		:						Any=1024  ,					_A		:						int=0.02  ,					_A		:						Optional[int]=1E-12  ,					_A		:						int=0  ,					_A		:						List[str]="absolute"  ,					_A		:						str=True  ,					_A		:						Union[str, Any]=False  ,					_A		:						List[str]=101  ,					_A		:						List[str]=102  ,					_A		:						List[Any]=None  ,					**_A		:						Union[str, Any]  ,					)  ->			Optional[Any]:
			super().__init__(bos_token_id=_A  ,					eos_token_id=_A  ,					pad_token_id=_A  ,					**_A      )

			if vision_config is None:
				__magic_name__	:   List[Any]					     =					{}
				logger.info('vision_config is None. initializing the GitVisionConfig with default values.'      )

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

			__magic_name__	:   Dict					     =					bos_token_id
			__magic_name__	:   List[str]					     =					eos_token_id







		def        __lowerCAmelCase		( self		:						Union[str, Any]      )  ->			List[str]:
			__magic_name__	:   Union[str, Any]					     =					copy.deepcopy(self.__dict__      )
			__magic_name__	:   List[str]					     =					self.vision_config.to_dict()
			__magic_name__	:   str					     =					self.__class__.model_type
			return output



'''simple docstring'''

from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_torch_available,
)


lowerCAmelCase				:str        =      {
    '''configuration_vision_encoder_decoder''': ['''VisionEncoderDecoderConfig''', '''VisionEncoderDecoderOnnxConfig''']
}

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							lowerCAmelCase				:List[str]        =      ['''VisionEncoderDecoderModel''']

try:
							if not is_tf_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							lowerCAmelCase				:List[str]        =      ['''TFVisionEncoderDecoderModel''']

try:
							if not is_flax_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							lowerCAmelCase				:Optional[Any]        =      ['''FlaxVisionEncoderDecoderModel''']

if TYPE_CHECKING:
							from .configuration_vision_encoder_decoder import VisionEncoderDecoderConfig, VisionEncoderDecoderOnnxConfig

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_vision_encoder_decoder import VisionEncoderDecoderModel

							try:
														if not is_tf_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_tf_vision_encoder_decoder import TFVisionEncoderDecoderModel

							try:
														if not is_flax_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_flax_vision_encoder_decoder import FlaxVisionEncoderDecoderModel

else:
							import sys

							lowerCAmelCase				:Tuple        =      _LazyModule(__name__, globals()['''__file__'''], _import_structure, module_spec=__spec__)