



"""simple docstring"""




from typing import Optional

from .. import Features, NamedSplit
from ..packaged_modules.text.text import Text
from ..utils.typing import NestedDataStructureLike, PathLike
from .abc import AbstractDatasetReader

class    _A	(     lowerCAmelCase__   ):



       def __init__(		self							:					Tuple					,		__SCREAMING_SNAKE_CASE							:					List[Any]					,		__SCREAMING_SNAKE_CASE							:					str = None					,		__SCREAMING_SNAKE_CASE							:					Optional[int] = None					,		__SCREAMING_SNAKE_CASE							:					int = None					,		__SCREAMING_SNAKE_CASE							:					Any = False					,		__SCREAMING_SNAKE_CASE							:					int = False					,		__SCREAMING_SNAKE_CASE							:					int = None					,		**__SCREAMING_SNAKE_CASE							:					Union[str, Any]					,		):


           '''simple docstring'''

           super().__init__(
               _SCREAMING_SNAKE_CASE					,		split=_SCREAMING_SNAKE_CASE					,		features=_SCREAMING_SNAKE_CASE					,		cache_dir=_SCREAMING_SNAKE_CASE					,		keep_in_memory=_SCREAMING_SNAKE_CASE					,		streaming=_SCREAMING_SNAKE_CASE					,		num_proc=_SCREAMING_SNAKE_CASE					,		**_SCREAMING_SNAKE_CASE					,		)
           __a							=    path_or_paths if isinstance(_SCREAMING_SNAKE_CASE					,		_SCREAMING_SNAKE_CASE) else {self.split: path_or_paths}
           __a							=    Text(
               cache_dir=_SCREAMING_SNAKE_CASE					,		data_files=_SCREAMING_SNAKE_CASE					,		features=_SCREAMING_SNAKE_CASE					,		**_SCREAMING_SNAKE_CASE					,		)





       def 		_lowerCamelCase      (		self							:					Dict):


           '''simple docstring'''

           if self.streaming:
               __a							=    self.builder.as_streaming_dataset(split=self.split)
           # Build regular (map-style) dataset
           else:
               __a							=    None
               __a							=    None
               __a							=    None
               __a							=    None

               self.builder.download_and_prepare(
                   download_config=_SCREAMING_SNAKE_CASE					,		download_mode=_SCREAMING_SNAKE_CASE					,		verification_mode=_SCREAMING_SNAKE_CASE					,		base_path=_SCREAMING_SNAKE_CASE					,		num_proc=self.num_proc					,		)
               __a							=    self.builder.as_dataset(
                   split=self.split					,		verification_mode=_SCREAMING_SNAKE_CASE					,		in_memory=self.keep_in_memory)
           return dataset










import unittest

from transformers import DonutProcessor


__snake_case						:List[str]						=					'''naver-clova-ix/donut-base'''

class    _A	(     unittest.TestCase   ):



       def 		_lowerCamelCase      (		self							:					List[str]):


           '''simple docstring'''

           __a							=    DonutProcessor.from_pretrained(__SCREAMING_SNAKE_CASE)





       def 		_lowerCamelCase      (		self							:					Tuple):


           '''simple docstring'''

           __a							=    {
               '''name''': '''John Doe''',
               '''age''': '''99''',
               '''city''': '''Atlanta''',
               '''state''': '''GA''',
               '''zip''': '''30301''',
               '''phone''': '''123-4567''',
               '''nicknames''': [{'''nickname''': '''Johnny'''}, {'''nickname''': '''JD'''}],
           }

           __a							=    (
               '''<s_name>John Doe</s_name><s_age>99</s_age><s_city>Atlanta</s_city>'''
               '''<s_state>GA</s_state><s_zip>30301</s_zip><s_phone>123-4567</s_phone>'''
               '''<s_nicknames><s_nickname>Johnny</s_nickname>'''
               '''<sep/><s_nickname>JD</s_nickname></s_nicknames>'''
           )
           __a							=    self.processor.tokenajson(__SCREAMING_SNAKE_CASE)

           self.assertDictEqual(__SCREAMING_SNAKE_CASE					,		__SCREAMING_SNAKE_CASE)





