






'''simple docstring'''







import inspect
import re
from hashlib import shaaaa
from typing import Dict, List

from .arrow import arrow
from .audiofolder import audiofolder
from .csv import csv
from .imagefolder import imagefolder
from .json import json
from .pandas import pandas
from .parquet import parquet
from .sql import sql  # noqa F401
from .text import text
def 						A__			(				__lowerCAmelCase		:			List[str]						):
						lowerCamelCase__         =  []
						for line in lines:
												lowerCamelCase__         =  re.sub(R"""#.*"""   ,    """"""   ,    __lowerCAmelCase						)  # remove comments
												if line:
																		filtered_lines.append(__lowerCAmelCase						)
						lowerCamelCase__         =  """\n""".join(__lowerCAmelCase						)

						# Make a hash from all this code
						lowerCamelCase__         =  full_str.encode("""utf-8"""						)
						return shaaaa(__lowerCAmelCase						).hexdigest()


# get importable module names and hash for caching
UpperCamelCase    :      Optional[Any]  			=		{
    'csv': (csv.__name__, _hash_python_lines(inspect.getsource(csv).splitlines())),
    'json': (json.__name__, _hash_python_lines(inspect.getsource(json).splitlines())),
    'pandas': (pandas.__name__, _hash_python_lines(inspect.getsource(pandas).splitlines())),
    'parquet': (parquet.__name__, _hash_python_lines(inspect.getsource(parquet).splitlines())),
    'arrow': (arrow.__name__, _hash_python_lines(inspect.getsource(arrow).splitlines())),
    'text': (text.__name__, _hash_python_lines(inspect.getsource(text).splitlines())),
    'imagefolder': (imagefolder.__name__, _hash_python_lines(inspect.getsource(imagefolder).splitlines())),
    'audiofolder': (audiofolder.__name__, _hash_python_lines(inspect.getsource(audiofolder).splitlines())),
}

# Used to infer the module to use based on the data files extensions
UpperCamelCase    :      List[str]  			=		{
    '.csv': ('csv', {}),
    '.tsv': ('csv', {'sep': '\t'}),
    '.json': ('json', {}),
    '.jsonl': ('json', {}),
    '.parquet': ('parquet', {}),
    '.arrow': ('arrow', {}),
    '.txt': ('text', {}),
}
_EXTENSION_TO_MODULE.update({ext: ('imagefolder', {}) for ext in imagefolder.ImageFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext.upper(): ('imagefolder', {}) for ext in imagefolder.ImageFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext: ('audiofolder', {}) for ext in audiofolder.AudioFolder.EXTENSIONS})
_EXTENSION_TO_MODULE.update({ext.upper(): ('audiofolder', {}) for ext in audiofolder.AudioFolder.EXTENSIONS})
UpperCamelCase    :      Dict  			=		{'imagefolder', 'audiofolder'}

# Used to filter data files based on extensions given a module name
UpperCamelCase    :      Dict[str, List[str]]  			=		{}
for _ext, (_module, _) in _EXTENSION_TO_MODULE.items():
							_MODULE_TO_EXTENSIONS.setdefault(_module, []).append(_ext)

_MODULE_TO_EXTENSIONS["imagefolder"].append('.zip')





_MODULE_TO_EXTENSIONS["audiofolder"].append('.zip')









'''simple docstring'''







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


UpperCamelCase    :      Tuple  			=		logging.get_logger(__name__)

UpperCamelCase    :      List[str]  			=		{
    'naver-clova-ix/donut-base': 'https://huggingface.co/naver-clova-ix/donut-base/resolve/main/config.json',
    # See all Donut models at https://huggingface.co/models?filter=donut-swin
}




class 		UpperCamelCase__    (a			):




		'''simple docstring'''





		_UpperCamelCase				  =					'donut-swin'

		_UpperCamelCase				  =					{
		    'num_attention_heads': 'num_heads',
		    'num_hidden_layers': 'num_layers',
		}






		def __init__(      self   ,_lowerCAmelCase=2_24   ,_lowerCAmelCase=4   ,_lowerCAmelCase=3   ,_lowerCAmelCase=96   ,_lowerCAmelCase=[2, 2, 6, 2]   ,_lowerCAmelCase=[3, 6, 12, 24]   ,_lowerCAmelCase=7   ,_lowerCAmelCase=4.0   ,_lowerCAmelCase=True   ,_lowerCAmelCase=0.0   ,_lowerCAmelCase=0.0   ,_lowerCAmelCase=0.1   ,_lowerCAmelCase="gelu"   ,_lowerCAmelCase=False   ,_lowerCAmelCase=0.02   ,_lowerCAmelCase=1E-5   ,**_lowerCAmelCase   ,):
								super().__init__(**_lowerCAmelCase       )

								lowerCamelCase__         =  image_size
								lowerCamelCase__         =  patch_size
								lowerCamelCase__         =  num_channels
								lowerCamelCase__         =  embed_dim
								lowerCamelCase__         =  depths
								lowerCamelCase__         =  len(_lowerCAmelCase       )
								lowerCamelCase__         =  num_heads
								lowerCamelCase__         =  window_size
								lowerCamelCase__         =  mlp_ratio
								lowerCamelCase__         =  qkv_bias
								lowerCamelCase__         =  hidden_dropout_prob
								lowerCamelCase__         =  attention_probs_dropout_prob
								lowerCamelCase__         =  drop_path_rate
								lowerCamelCase__         =  hidden_act
								lowerCamelCase__         =  use_absolute_embeddings
								lowerCamelCase__         =  layer_norm_eps
								lowerCamelCase__         =  initializer_range
								# we set the hidden_size attribute in order to make Swin work with VisionEncoderDecoderModel
								# this indicates the channel dimension after the last stage of the model
								lowerCamelCase__         =  int(embed_dim * 2 ** (len(_lowerCAmelCase       ) - 1)       )

