



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


SCREAMING_SNAKE_CASE     				=						logging.get_logger(__name__)

SCREAMING_SNAKE_CASE     				=						{
    "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 	lowerCamelCase      (						lowercase__  ):







     '''simple docstring'''







     lowerCAmelCase_				:    List[Any]									=  'trocr'
     lowerCAmelCase_				:    Union[str, Any]									=  ['past_key_values']
     lowerCAmelCase_				:    List[Any]									=  {
         'num_attention_heads': 'decoder_attention_heads',
         'hidden_size': 'd_model',
         'num_hidden_layers': 'decoder_layers',
     }



     def __init__(			self    ,	lowerCAmelCase=5_0265    ,	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    ,	)






def snake_case__  (			__SCREAMING_SNAKE_CASE			,     __SCREAMING_SNAKE_CASE )		->							Union[str, Any]:
		UpperCAmelCase_						=				0
		while b > 0:
				if b & 1:
						res += a

				a += a
				b >>= 1

		return res







def snake_case__  (			__SCREAMING_SNAKE_CASE			,     __SCREAMING_SNAKE_CASE			,     __SCREAMING_SNAKE_CASE )		->							Tuple:
		UpperCAmelCase_						=				0
		while b > 0:
				if b & 1:
						UpperCAmelCase_						=				((res % c) + (a % c)) % c

				a += a
				b >>= 1

		return res

