



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


lowercase_	       =			logging.get_logger(__name__)

lowercase_	       =			{
    '''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 						__a (     SCREAMING_SNAKE_CASE				):
	SCREAMING_SNAKE_CASE       =       "trocr"
	SCREAMING_SNAKE_CASE       =       ["past_key_values"]
	SCREAMING_SNAKE_CASE       =       {
	    "num_attention_heads": "decoder_attention_heads",
	    "hidden_size": "d_model",
	    "num_hidden_layers": "decoder_layers",
	}



	def __init__(						self							:    Union[str, Any]				,	snake_case_							:    Any=5_02_65				,	snake_case_							:    Dict=10_24				,	snake_case_							:    int=12				,	snake_case_							:    str=16				,	snake_case_							:    List[Any]=40_96				,	snake_case_							:    List[Any]="gelu"				,	snake_case_							:    Tuple=5_12				,	snake_case_							:    int=0.1				,	snake_case_							:    Optional[Any]=0.0				,	snake_case_							:    Optional[Any]=0.0				,	snake_case_							:    Optional[int]=2				,	snake_case_							:    List[str]=0.0_2				,	snake_case_							:    Optional[int]=0.0				,	snake_case_							:    Optional[int]=True				,	snake_case_							:    Optional[Any]=False				,	snake_case_							:    Tuple=True				,	snake_case_							:    Any=True				,	snake_case_							:    Any=1				,	snake_case_							:    Tuple=0				,	snake_case_							:    Dict=2				,	**snake_case_							:    int				,	)->							List[str]:
						__lowerCAmelCase	   =vocab_size
						__lowerCAmelCase	   =d_model
						__lowerCAmelCase	   =decoder_layers
						__lowerCAmelCase	   =decoder_attention_heads
						__lowerCAmelCase	   =decoder_ffn_dim
						__lowerCAmelCase	   =activation_function
						__lowerCAmelCase	   =max_position_embeddings
						__lowerCAmelCase	   =dropout
						__lowerCAmelCase	   =attention_dropout
						__lowerCAmelCase	   =activation_dropout
						__lowerCAmelCase	   =init_std
						__lowerCAmelCase	   =decoder_layerdrop
						__lowerCAmelCase	   =use_cache
						__lowerCAmelCase	   =scale_embedding
						__lowerCAmelCase	   =use_learned_position_embeddings
						__lowerCAmelCase	   =layernorm_embedding

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









def 					__lowerCAmelCase		(  __lowerCamelCase	:    list				,   __lowerCamelCase	:    int				,   __lowerCamelCase	:    int = 0				,   __lowerCamelCase	:    int = 0	)  ->						int:
					__lowerCAmelCase	   =right or len(__lowerCamelCase	) - 1
					if left > right:
										return -1
					elif list_data[left] == key:
										return left
					elif list_data[right] == key:
										return right
					else:
										return search(__lowerCamelCase				,   __lowerCamelCase				,   left + 1				,   right - 1	)


if __name__ == "__main__":
				import doctest

				doctest.testmod()




