






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


UpperCamelCase__     =	logging.get_logger(__name__)

UpperCamelCase__     =	{
    '''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__    ):
							snake_case       : Optional[Any]         =    'trocr'
							snake_case       : Union[str, Any]         =    ['past_key_values']
							snake_case       : str         =    {
							    'num_attention_heads': 'decoder_attention_heads',
							    'hidden_size': 'd_model',
							    'num_hidden_layers': 'decoder_layers',
							}






							def __init__(  self					,	__lowerCAmelCase=50265					,	__lowerCAmelCase=1024					,	__lowerCAmelCase=12					,	__lowerCAmelCase=16					,	__lowerCAmelCase=4096					,	__lowerCAmelCase="gelu"					,	__lowerCAmelCase=512					,	__lowerCAmelCase=0.1					,	__lowerCAmelCase=0.0					,	__lowerCAmelCase=0.0					,	__lowerCAmelCase=2					,	__lowerCAmelCase=0.02					,	__lowerCAmelCase=0.0					,	__lowerCAmelCase=True					,	__lowerCAmelCase=False					,	__lowerCAmelCase=True					,	__lowerCAmelCase=True					,	__lowerCAmelCase=1					,	__lowerCAmelCase=0					,	__lowerCAmelCase=2					,	**__lowerCAmelCase					,	):
														UpperCamelCase__			       =     vocab_size
														UpperCamelCase__			       =     d_model
														UpperCamelCase__			       =     decoder_layers
														UpperCamelCase__			       =     decoder_attention_heads
														UpperCamelCase__			       =     decoder_ffn_dim
														UpperCamelCase__			       =     activation_function
														UpperCamelCase__			       =     max_position_embeddings
														UpperCamelCase__			       =     dropout
														UpperCamelCase__			       =     attention_dropout
														UpperCamelCase__			       =     activation_dropout
														UpperCamelCase__			       =     init_std
														UpperCamelCase__			       =     decoder_layerdrop
														UpperCamelCase__			       =     use_cache
														UpperCamelCase__			       =     scale_embedding
														UpperCamelCase__			       =     use_learned_position_embeddings
														UpperCamelCase__			       =     layernorm_embedding

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











import copy

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


UpperCamelCase__     =	logging.get_logger(__name__)

class     __SCREAMING_SNAKE_CASE   (       _a    ):
							snake_case       : List[Any]         =    """upernet"""






							def __init__(  self					,	__lowerCAmelCase=None					,	__lowerCAmelCase=512					,	__lowerCAmelCase=0.02					,	__lowerCAmelCase=[1, 2, 3, 6]					,	__lowerCAmelCase=True					,	__lowerCAmelCase=0.4					,	__lowerCAmelCase=384					,	__lowerCAmelCase=256					,	__lowerCAmelCase=1					,	__lowerCAmelCase=False					,	__lowerCAmelCase=255					,	**__lowerCAmelCase					,	):
														super().__init__(**__lowerCAmelCase					)

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

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







							def 			_lowerCamelCase						(  self					):
														UpperCamelCase__			       =     copy.deepcopy(self.__dict__					)
														UpperCamelCase__			       =     self.backbone_config.to_dict()
														UpperCamelCase__			       =     self.__class__.model_type
														return output




