






'''simple docstring'''







import copy
import os
from typing import Union

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


_A			:    Optional[int]					  =logging.get_logger(__name__)

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

class _lowercase			(       _lowercase	):
							a          = """git_vision_model"""




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

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




							@classmethod
							def 	lowerCamelCase_       (							cls:       Dict    ,							UpperCamelCase__:       Union[str, os.PathLike]    ,							**UpperCamelCase__:       List[str]  ):
														cls._set_token_in_kwargs(UpperCamelCase__  )

														lowerCamelCase__						,	lowerCamelCase__      :			Dict 						= cls.get_config_dict(UpperCamelCase__    ,							**UpperCamelCase__  )

														# get the vision config dict if we are loading from GITConfig
														if config_dict.get("""model_type"""  ) == "git":
																					lowerCamelCase__      :			int 						= 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(UpperCamelCase__    ,							**UpperCamelCase__  )



class _lowercase			(       _lowercase	):
							a          = """git"""




							def __init__(							self:       Dict    ,							UpperCamelCase__:       Dict=None    ,							UpperCamelCase__:       int=30_522    ,							UpperCamelCase__:       Optional[int]=768    ,							UpperCamelCase__:       Tuple=6    ,							UpperCamelCase__:       int=12    ,							UpperCamelCase__:       int=3_072    ,							UpperCamelCase__:       str="gelu"    ,							UpperCamelCase__:       Any=0.1    ,							UpperCamelCase__:       Optional[int]=0.1    ,							UpperCamelCase__:       Optional[int]=1_024    ,							UpperCamelCase__:       Any=0.02    ,							UpperCamelCase__:       Union[str, Any]=1e-12    ,							UpperCamelCase__:       Dict=0    ,							UpperCamelCase__:       Any="absolute"    ,							UpperCamelCase__:       Dict=True    ,							UpperCamelCase__:       Any=False    ,							UpperCamelCase__:       List[Any]=101    ,							UpperCamelCase__:       Union[str, Any]=102    ,							UpperCamelCase__:       Union[str, Any]=None    ,							**UpperCamelCase__:       Optional[Any]    ,							):
														super().__init__(bos_token_id=UpperCamelCase__    ,							eos_token_id=UpperCamelCase__    ,							pad_token_id=UpperCamelCase__    ,							**UpperCamelCase__  )

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

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

														lowerCamelCase__      :			Union[str, Any] 						= bos_token_id
														lowerCamelCase__      :			Union[str, Any] 						= eos_token_id




							def 	lowerCamelCase_       (							self:       Optional[Any]  ):
														lowerCamelCase__      :			Optional[Any] 						= copy.deepcopy(self.__dict__  )
														lowerCamelCase__      :			Union[str, Any] 						= self.vision_config.to_dict()
														lowerCamelCase__      :			Optional[Any] 						= self.__class__.model_type
														return output









'''simple docstring'''







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


_A			:    Any					  =logging.get_logger(__name__)

_A			:    Dict					  ={
    '''microsoft/trocr-base-handwritten''': (
        '''https://huggingface.co/microsoft/trocr-base-handwritten/resolve/main/config.json'''
    ),
    # See all TrOCR models at https://huggingface.co/models?filter=trocr
}

class _lowercase			(       _lowercase	):
							a          = """trocr"""
							a          = ["""past_key_values"""]
							a          = {
							    """num_attention_heads""": """decoder_attention_heads""",
							    """hidden_size""": """d_model""",
							    """num_hidden_layers""": """decoder_layers""",
							}




							def __init__(							self:       Optional[Any]    ,							UpperCamelCase__:       int=50_265    ,							UpperCamelCase__:       int=1_024    ,							UpperCamelCase__:       Optional[Any]=12    ,							UpperCamelCase__:       Dict=16    ,							UpperCamelCase__:       int=4_096    ,							UpperCamelCase__:       Tuple="gelu"    ,							UpperCamelCase__:       int=512    ,							UpperCamelCase__:       Dict=0.1    ,							UpperCamelCase__:       Tuple=0.0    ,							UpperCamelCase__:       str=0.0    ,							UpperCamelCase__:       Any=2    ,							UpperCamelCase__:       Dict=0.02    ,							UpperCamelCase__:       Optional[Any]=0.0    ,							UpperCamelCase__:       str=True    ,							UpperCamelCase__:       Tuple=False    ,							UpperCamelCase__:       Union[str, Any]=True    ,							UpperCamelCase__:       Tuple=True    ,							UpperCamelCase__:       Dict=1    ,							UpperCamelCase__:       List[str]=0    ,							UpperCamelCase__:       Union[str, Any]=2    ,							**UpperCamelCase__:       str    ,							):
														lowerCamelCase__      :			Any 						= vocab_size
														lowerCamelCase__      :			Tuple 						= d_model
														lowerCamelCase__      :			Any 						= decoder_layers
														lowerCamelCase__      :			Dict 						= decoder_attention_heads
														lowerCamelCase__      :			str 						= decoder_ffn_dim
														lowerCamelCase__      :			Tuple 						= activation_function
														lowerCamelCase__      :			Dict 						= max_position_embeddings
														lowerCamelCase__      :			int 						= dropout
														lowerCamelCase__      :			int 						= attention_dropout
														lowerCamelCase__      :			List[Any] 						= activation_dropout
														lowerCamelCase__      :			Union[str, Any] 						= init_std
														lowerCamelCase__      :			Optional[int] 						= decoder_layerdrop
														lowerCamelCase__      :			Dict 						= use_cache
														lowerCamelCase__      :			Any 						= scale_embedding
														lowerCamelCase__      :			Optional[int] 						= use_learned_position_embeddings
														lowerCamelCase__      :			List[str] 						= layernorm_embedding

														super().__init__(
														    pad_token_id=UpperCamelCase__    ,							bos_token_id=UpperCamelCase__    ,							eos_token_id=UpperCamelCase__    ,							decoder_start_token_id=UpperCamelCase__    ,							**UpperCamelCase__    ,							)

