



"""simple docstring"""


import unittest

from transformers import DonutProcessor


__A   :							Any										=   "naver-clova-ix/donut-base"
class 			_a (					unittest.TestCase):
			"""simple docstring"""



			def  lowercase__						(		self     :    int   )->str:
							_UpperCAmelCase					=    DonutProcessor.from_pretrained(__UpperCamelCase   )



			def  lowercase__						(		self     :    Optional[Any]   )->List[str]:
							_UpperCAmelCase					=    {
							    '''name''': '''John Doe''',
							    '''age''': '''99''',
							    '''city''': '''Atlanta''',
							    '''state''': '''GA''',
							    '''zip''': '''30301''',
							    '''phone''': '''123-4567''',
							    '''nicknames''': [{'''nickname''': '''Johnny'''}, {'''nickname''': '''JD'''}],
							}

							_UpperCAmelCase					=    (
							    '''<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>'''
							)
							_UpperCAmelCase					=    self.processor.tokenajson(__UpperCamelCase   )

							self.assertDictEqual(__UpperCamelCase				,   __UpperCamelCase   )








"""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):
			"""simple docstring"""



			def __init__(		self     :    List[str]				,   __UpperCamelCase     :    NestedDataStructureLike[PathLike]				,   __UpperCamelCase     :    Optional[NamedSplit] = None				,   __UpperCamelCase     :    Optional[Features] = None				,   __UpperCamelCase     :    str = None				,   __UpperCamelCase     :    bool = False				,   __UpperCamelCase     :    bool = False				,   __UpperCamelCase     :    Optional[int] = None				,   **__UpperCamelCase     :    Optional[Any]				,   )->Any:
							super().__init__(
							    __UpperCamelCase				,   split=__UpperCamelCase				,   features=__UpperCamelCase				,   cache_dir=__UpperCamelCase				,   keep_in_memory=__UpperCamelCase				,   streaming=__UpperCamelCase				,   num_proc=__UpperCamelCase				,   **__UpperCamelCase				,   )
							_UpperCAmelCase					=    path_or_paths if isinstance(__UpperCamelCase				,   __UpperCamelCase   ) else {self.split: path_or_paths}
							_UpperCAmelCase					=    Text(
							    cache_dir=__UpperCamelCase				,   data_files=__UpperCamelCase				,   features=__UpperCamelCase				,   **__UpperCamelCase				,   )



			def  lowercase__						(		self     :    Optional[Any]   )->str:
							# Build iterable dataset
							if self.streaming:
											_UpperCAmelCase					=    self.builder.as_streaming_dataset(split=self.split   )
							# Build regular (map-style) dataset
							else:
											_UpperCAmelCase					=    None
											_UpperCAmelCase					=    None
											_UpperCAmelCase					=    None
											_UpperCAmelCase					=    None

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



