

"""simple docstring"""





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


__UpperCamelCase  :      List[str]							      =		logging.get_logger(__name__)

__UpperCamelCase  :      List[Any]							      =		{
    '''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 				SCREAMING_SNAKE_CASE					(		a_       ):






					"""simple docstring"""



					lowercase__				 =       "trocr"
					lowercase__				 =       ["past_key_values"]
					lowercase__				 =       {
					    "num_attention_heads": "decoder_attention_heads",
					    "hidden_size": "d_model",
					    "num_hidden_layers": "decoder_layers",
					}







					def __init__(       self			:				str   ,lowercase_			:				Optional[int]=5_0_2_6_5   ,lowercase_			:				Dict=1_0_2_4   ,lowercase_			:				int=1_2   ,lowercase_			:				Tuple=1_6   ,lowercase_			:				Any=4_0_9_6   ,lowercase_			:				Any="gelu"   ,lowercase_			:				Tuple=5_1_2   ,lowercase_			:				Optional[Any]=0.1   ,lowercase_			:				Optional[int]=0.0   ,lowercase_			:				Any=0.0   ,lowercase_			:				Optional[Any]=2   ,lowercase_			:				Any=0.02   ,lowercase_			:				str=0.0   ,lowercase_			:				Optional[int]=True   ,lowercase_			:				str=False   ,lowercase_			:				Optional[int]=True   ,lowercase_			:				Union[str, Any]=True   ,lowercase_			:				str=1   ,lowercase_			:				Dict=0   ,lowercase_			:				List[str]=2   ,**lowercase_			:				Union[str, Any]   ,):
						lowerCAmelCase__	:						Dict  				=	vocab_size
						lowerCAmelCase__	:						List[Any]  				=	d_model
						lowerCAmelCase__	:						Dict  				=	decoder_layers
						lowerCAmelCase__	:						List[Any]  				=	decoder_attention_heads
						lowerCAmelCase__	:						Optional[Any]  				=	decoder_ffn_dim
						lowerCAmelCase__	:						str  				=	activation_function
						lowerCAmelCase__	:						List[str]  				=	max_position_embeddings
						lowerCAmelCase__	:						int  				=	dropout
						lowerCAmelCase__	:						Union[str, Any]  				=	attention_dropout
						lowerCAmelCase__	:						str  				=	activation_dropout
						lowerCAmelCase__	:						int  				=	init_std
						lowerCAmelCase__	:						int  				=	decoder_layerdrop
						lowerCAmelCase__	:						Optional[Any]  				=	use_cache
						lowerCAmelCase__	:						Any  				=	scale_embedding
						lowerCAmelCase__	:						List[Any]  				=	use_learned_position_embeddings
						lowerCAmelCase__	:						Any  				=	layernorm_embedding

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






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			:Union[str, Any]         =	'upernet'
	def __init__(       self  :			Dict       ,							SCREAMING_SNAKE_CASE_  :			Dict=None       ,							SCREAMING_SNAKE_CASE_  :			str=5_1_2       ,							SCREAMING_SNAKE_CASE_  :			Tuple=0.02       ,							SCREAMING_SNAKE_CASE_  :			Optional[Any]=[1, 2, 3, 6]       ,							SCREAMING_SNAKE_CASE_  :			Optional[int]=True       ,							SCREAMING_SNAKE_CASE_  :			Tuple=0.4       ,							SCREAMING_SNAKE_CASE_  :			Optional[int]=3_8_4       ,							SCREAMING_SNAKE_CASE_  :			str=2_5_6       ,							SCREAMING_SNAKE_CASE_  :			Dict=1       ,							SCREAMING_SNAKE_CASE_  :			Tuple=False       ,							SCREAMING_SNAKE_CASE_  :			str=2_5_5       ,							**SCREAMING_SNAKE_CASE_  :			str       ,							)       ->     int:
					super().__init__(**SCREAMING_SNAKE_CASE_       )

					if backbone_config is None:
									logger.info('''`backbone_config` is `None`. Initializing the config with the default `ResNet` backbone.'''       )
									lowercase_       =					CONFIG_MAPPING['''resnet'''](out_features=['''stage1''', '''stage2''', '''stage3''', '''stage4''']       )
					elif isinstance(SCREAMING_SNAKE_CASE_       ,							SCREAMING_SNAKE_CASE_       ):
									lowercase_       =					backbone_config.get('''model_type'''       )
									lowercase_       =					CONFIG_MAPPING[backbone_model_type]
									lowercase_       =					config_class.from_dict(SCREAMING_SNAKE_CASE_       )

					lowercase_       =					backbone_config
					lowercase_       =					hidden_size
					lowercase_       =					initializer_range
					lowercase_       =					pool_scales
					lowercase_       =					use_auxiliary_head
					lowercase_       =					auxiliary_loss_weight
					lowercase_       =					auxiliary_in_channels
					lowercase_       =					auxiliary_channels
					lowercase_       =					auxiliary_num_convs
					lowercase_       =					auxiliary_concat_input
					lowercase_       =					loss_ignore_index




	def 						_lowercase  (       self  :			List[str]       )       ->     List[str]:
					lowercase_       =					copy.deepcopy(self.__dict__       )
					lowercase_       =					self.backbone_config.to_dict()
					lowercase_       =					self.__class__.model_type
					return output




