





from typing import List

from .keymap import KEYMAP, get_character



def    __lowercase   (      _SCREAMING_SNAKE_CASE	) ->   Optional[int]:


      '''simple docstring'''


      def decorator(_SCREAMING_SNAKE_CASE	):
            SCREAMING_SNAKE_CASE		=						getattr(_SCREAMING_SNAKE_CASE ,						"""handle_key""" ,						[]	)
            handle += [key]
            setattr(_SCREAMING_SNAKE_CASE ,						"""handle_key""" ,						_SCREAMING_SNAKE_CASE	)
            return func

      return decorator



def    __lowercase   (      *_SCREAMING_SNAKE_CASE	) ->   List[Any]:


      '''simple docstring'''


      def decorator(_SCREAMING_SNAKE_CASE	):
            SCREAMING_SNAKE_CASE		=						getattr(_SCREAMING_SNAKE_CASE ,						"""handle_key""" ,						[]	)
            handle += keys
            setattr(_SCREAMING_SNAKE_CASE ,						"""handle_key""" ,						_SCREAMING_SNAKE_CASE	)
            return func

      return decorator

class 		UpperCamelCase__ (      lowerCAmelCase_   ):



     '''simple docstring'''

     def __new__(							cls						:    Tuple						,lowerCamelCase__						:    Union[str, Any]						,lowerCamelCase__						:    List[str]						,lowerCamelCase__						:    Any       )     ->		Dict:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						super().__new__(cls						,lowerCamelCase__						,lowerCamelCase__						,lowerCamelCase__       )
           if not hasattr(lowerCamelCase__						,"""key_handler"""       ):
                 setattr(lowerCamelCase__						,"""key_handler"""						,{}       )
           setattr(lowerCamelCase__						,"""handle_input"""						,KeyHandler.handle_input       )

           for value in attrs.values():
                 SCREAMING_SNAKE_CASE		=						getattr(lowerCamelCase__						,"""handle_key"""						,[]       )
                 for key in handled_keys:
                       SCREAMING_SNAKE_CASE		=						value
           return new_cls






     @staticmethod
     def 				SCREAMING_SNAKE_CASE__  (							cls						:    Union[str, Any]       )     ->		Tuple:




           '''simple docstring'''


           SCREAMING_SNAKE_CASE		=						get_character()
           if char != KEYMAP["undefined"]:
                 SCREAMING_SNAKE_CASE		=						ord(lowerCamelCase__       )
           SCREAMING_SNAKE_CASE		=						cls.key_handler.get(lowerCamelCase__       )
           if handler:
                 SCREAMING_SNAKE_CASE		=						char
                 return handler(cls       )
           else:
                 return None



def    __lowercase   (      cls	) ->   Optional[Any]:


      '''simple docstring'''


      return KeyHandler(cls.__name__ ,						cls.__bases__ ,						cls.__dict__.copy()	)









from typing import Callable, Optional

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

class 		UpperCamelCase__ (      lowerCAmelCase_   ):



     '''simple docstring'''

     def __init__(							self						:    Union[str, Any]						,lowerCamelCase__						:    Callable						,lowerCamelCase__						:    Optional[Features] = None						,lowerCamelCase__						:    str = None						,lowerCamelCase__						:    bool = False						,lowerCamelCase__						:    bool = False						,lowerCamelCase__						:    Optional[dict] = None						,lowerCamelCase__						:    Optional[int] = None						,**lowerCamelCase__						:    Optional[Any]						,)     ->		List[str]:




           '''simple docstring'''


           super().__init__(
               features=lowerCamelCase__						,cache_dir=lowerCamelCase__						,keep_in_memory=lowerCamelCase__						,streaming=lowerCamelCase__						,num_proc=lowerCamelCase__						,**lowerCamelCase__						,)
           SCREAMING_SNAKE_CASE		=						Generator(
               cache_dir=lowerCamelCase__						,features=lowerCamelCase__						,generator=lowerCamelCase__						,gen_kwargs=lowerCamelCase__						,**lowerCamelCase__						,)






     def 				SCREAMING_SNAKE_CASE__  (							self						:    Union[str, Any]       )     ->		Optional[Any]:




           '''simple docstring'''


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

                 self.builder.download_and_prepare(
                     download_config=lowerCamelCase__						,download_mode=lowerCamelCase__						,verification_mode=lowerCamelCase__						,base_path=lowerCamelCase__						,num_proc=self.num_proc						,)
                 SCREAMING_SNAKE_CASE		=						self.builder.as_dataset(
                     split="""train"""						,verification_mode=lowerCamelCase__						,in_memory=self.keep_in_memory       )
           return dataset


