






'''simple docstring'''


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


lowerCamelCase_				: str    	=							logging.get_logger(__name__)

lowerCamelCase_				: Tuple    	=							{
    '''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							(		SCREAMING_SNAKE_CASE	):


			'''simple docstring'''





			__a							:							Any					     =					"trocr"
			__a							:							int					     =					["past_key_values"]
			__a							:							Dict					     =					{
			    "num_attention_heads": "decoder_attention_heads",
			    "hidden_size": "d_model",
			    "num_hidden_layers": "decoder_layers",
			}






			def __init__(   self							:						int ,      lowercase							:						Optional[int]=5_0_2_6_5 ,      lowercase							:						str=1_0_2_4 ,      lowercase							:						Optional[Any]=1_2 ,      lowercase							:						Tuple=1_6 ,      lowercase							:						Dict=4_0_9_6 ,      lowercase							:						List[Any]="gelu" ,      lowercase							:						int=5_1_2 ,      lowercase							:						Dict=0.1 ,      lowercase							:						str=0.0 ,      lowercase							:						List[str]=0.0 ,      lowercase							:						Optional[int]=2 ,      lowercase							:						List[str]=0.0_2 ,      lowercase							:						Any=0.0 ,      lowercase							:						List[Any]=True ,      lowercase							:						Optional[Any]=False ,      lowercase							:						Optional[int]=True ,      lowercase							:						Any=True ,      lowercase							:						Dict=1 ,      lowercase							:						Optional[Any]=0 ,      lowercase							:						str=2 ,      **lowercase							:						Union[str, Any] ,      )							->    List[Any]:

									'''simple docstring'''







									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=lowercase ,      bos_token_id=lowercase ,      eos_token_id=lowercase ,      decoder_start_token_id=lowercase ,      **lowercase ,      )








'''simple docstring'''


import enum
import os
from hashlib import shaaaa
from typing import Optional

from .. import config
from .logging import get_logger


lowerCamelCase_				: Any    	=							get_logger(__name__)
class    _SCREAMING_SNAKE_CASE							(		enum.Enum	):


			'''simple docstring'''





			__a							:							Tuple					     =					"all_checks"
			__a							:							List[Any]					     =					"basic_checks"
			__a							:							Dict					     =					"no_checks"
class    _SCREAMING_SNAKE_CASE							(		SCREAMING_SNAKE_CASE	):


			'''simple docstring'''





class    _SCREAMING_SNAKE_CASE							(		SCREAMING_SNAKE_CASE	):


			'''simple docstring'''





class    _SCREAMING_SNAKE_CASE							(		SCREAMING_SNAKE_CASE	):


			'''simple docstring'''





class    _SCREAMING_SNAKE_CASE							(		SCREAMING_SNAKE_CASE	):


			'''simple docstring'''












def 	__magic_name__( _A						,      _A						,      _A=None					):
						'''simple docstring'''





						if expected_checksums is None:
												logger.info("""Unable to verify checksums."""					)
												return
						if len(set(_A					) - set(_A					)					) > 0:
												raise ExpectedMoreDownloadedFiles(str(set(_A					) - set(_A					)					)					)
						if len(set(_A					) - set(_A					)					) > 0:
												raise UnexpectedDownloadedFile(str(set(_A					) - set(_A					)					)					)
						UpperCamelCase__         = [url for url in expected_checksums if expected_checksums[url] != recorded_checksums[url]]
						UpperCamelCase__         = """ for """ + verification_name if verification_name is not None else """"""
						if len(_A					) > 0:
												raise NonMatchingChecksumError(
												    f"Checksums didn't match{for_verification_name}:\n"
												    f"{bad_urls}\n"
												    """Set `verification_mode='no_checks'` to skip checksums verification and ignore this error"""					)
						logger.info("""All the checksums matched successfully""" + for_verification_name					)
class    _SCREAMING_SNAKE_CASE							(		SCREAMING_SNAKE_CASE	):


			'''simple docstring'''





class    _SCREAMING_SNAKE_CASE							(		SCREAMING_SNAKE_CASE	):


			'''simple docstring'''





class    _SCREAMING_SNAKE_CASE							(		SCREAMING_SNAKE_CASE	):


			'''simple docstring'''





class    _SCREAMING_SNAKE_CASE							(		SCREAMING_SNAKE_CASE	):


			'''simple docstring'''












def 	__magic_name__( _A						,      _A					):
						'''simple docstring'''





						if expected_splits is None:
												logger.info("""Unable to verify splits sizes."""					)
												return
						if len(set(_A					) - set(_A					)					) > 0:
												raise ExpectedMoreSplits(str(set(_A					) - set(_A					)					)					)
						if len(set(_A					) - set(_A					)					) > 0:
												raise UnexpectedSplits(str(set(_A					) - set(_A					)					)					)
						UpperCamelCase__         = [
						    {"""expected""": expected_splits[name], """recorded""": recorded_splits[name]}
						    for name in expected_splits
						    if expected_splits[name].num_examples != recorded_splits[name].num_examples
						]
						if len(_A					) > 0:
												raise NonMatchingSplitsSizesError(str(_A					)					)
						logger.info("""All the splits matched successfully."""					)







def 	__magic_name__( _A						,      _A = True					):
						'''simple docstring'''





						if record_checksum:
												UpperCamelCase__         = shaaaa()
												with open(_A						,      """rb"""					) as f:
																		for chunk in iter(lambda: f.read(1 << 20					)						,      B""""""					):
																								m.update(_A					)
																		UpperCamelCase__         = m.hexdigest()
						else:
												UpperCamelCase__         = None
						return {"num_bytes": os.path.getsize(_A					), "checksum": checksum}







def 	__magic_name__( _A					):
						'''simple docstring'''





						if dataset_size and config.IN_MEMORY_MAX_SIZE:
												return dataset_size < config.IN_MEMORY_MAX_SIZE
						else:
												return False
