
'''simple docstring'''

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


UpperCAmelCase__ :			Tuple											=		logging.get_logger(__name__)

UpperCAmelCase__ :			int											=		{
    "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__     ):
	snake_case__   :int   =  'trocr'
	snake_case__   :Any   =  ['past_key_values']
	snake_case__   :Tuple   =  {
	    'num_attention_heads': 'decoder_attention_heads',
	    'hidden_size': 'd_model',
	    'num_hidden_layers': 'decoder_layers',
	}





	def __init__(       self      :							Optional[Any]   ,				__magic_name__      :							Dict=50265   ,				__magic_name__      :							Union[str, Any]=1024   ,				__magic_name__      :							Optional[Any]=12   ,				__magic_name__      :							int=16   ,				__magic_name__      :							Optional[Any]=4096   ,				__magic_name__      :							Union[str, Any]="gelu"   ,				__magic_name__      :							Dict=512   ,				__magic_name__      :							Union[str, Any]=0.1   ,				__magic_name__      :							Union[str, Any]=0.0   ,				__magic_name__      :							str=0.0   ,				__magic_name__      :							Optional[Any]=2   ,				__magic_name__      :							Optional[Any]=0.02   ,				__magic_name__      :							Tuple=0.0   ,				__magic_name__      :							Optional[int]=True   ,				__magic_name__      :							Dict=False   ,				__magic_name__      :							str=True   ,				__magic_name__      :							Any=True   ,				__magic_name__      :							Union[str, Any]=1   ,				__magic_name__      :							Dict=0   ,				__magic_name__      :							Optional[int]=2   ,				**__magic_name__      :							int   ,				):


				"""simple docstring"""

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










from typing import Callable, Optional

from .. import Features
from ..packaged_modules.generator.generator import Generator
from .abc import AbstractDatasetInputStream



class 			__lowerCAmelCase  (						lowerCAmelCase__ ):




 def __init__(    self						,					__UpperCAmelCase						,					__UpperCAmelCase = None						,					__UpperCAmelCase = None						,					__UpperCAmelCase = False						,					__UpperCAmelCase = False						,					__UpperCAmelCase = None						,					__UpperCAmelCase = None						,					**__UpperCAmelCase						,					):



    '''simple docstring'''
    super().__init__(
        features=__UpperCAmelCase						,					cache_dir=__UpperCAmelCase						,					keep_in_memory=__UpperCAmelCase						,					streaming=__UpperCAmelCase						,					num_proc=__UpperCAmelCase						,					**__UpperCAmelCase						,					)
    __lowerCamelCase    				=     Generator(
        cache_dir=__UpperCAmelCase						,					features=__UpperCAmelCase						,					generator=__UpperCAmelCase						,					gen_kwargs=__UpperCAmelCase						,					**__UpperCAmelCase						,					)




 def 							lowerCamelCase   (    self					):



    '''simple docstring'''
    # Build iterable dataset
    if self.streaming:
       __lowerCamelCase    				=     self.builder.as_streaming_dataset(split='''train'''					)
    # Build regular (map-style) dataset
    else:
       __lowerCamelCase    				=     None
       __lowerCamelCase    				=     None
       __lowerCamelCase    				=     None
       __lowerCamelCase    				=     None

       self.builder.download_and_prepare(
           download_config=__UpperCAmelCase						,					download_mode=__UpperCAmelCase						,					verification_mode=__UpperCAmelCase						,					base_path=__UpperCAmelCase						,					num_proc=self.num_proc						,					)
       __lowerCamelCase    				=     self.builder.as_dataset(
           split='''train'''						,					verification_mode=__UpperCAmelCase						,					in_memory=self.keep_in_memory					)
    return dataset






