





'''simple docstring'''

import os
import string
import sys


a        =						1 << 8

a        =						{
    'tab': ord("\t"),
    'newline': ord("\r"),
    'esc': 27,
    'up': 65 + ARROW_KEY_FLAG,
    'down': 66 + ARROW_KEY_FLAG,
    'right': 67 + ARROW_KEY_FLAG,
    'left': 68 + ARROW_KEY_FLAG,
    'mod_int': 91,
    'undefined': sys.maxsize,
    'interrupt': 3,
    'insert': 50,
    'delete': 51,
    'pg_up': 53,
    'pg_down': 54,
}

a        =						KEYMAP['up']
a        =						KEYMAP['left']

if sys.platform == "win32":
 a        =						[]
 a        =						{
     b'\xe0H': KEYMAP['up'] - ARROW_KEY_FLAG,
     b'\x00H': KEYMAP['up'] - ARROW_KEY_FLAG,
     b'\xe0P': KEYMAP['down'] - ARROW_KEY_FLAG,
     b'\x00P': KEYMAP['down'] - ARROW_KEY_FLAG,
     b'\xe0M': KEYMAP['right'] - ARROW_KEY_FLAG,
     b'\x00M': KEYMAP['right'] - ARROW_KEY_FLAG,
     b'\xe0K': KEYMAP['left'] - ARROW_KEY_FLAG,
     b'\x00K': KEYMAP['left'] - ARROW_KEY_FLAG,
 }

for i in range(10):
 a        =						ord(str(i))

def 						__magic_name__       (							)						->					int:

   '''simple docstring'''







   if os.name == "nt":
      import msvcrt

      __SCREAMING_SNAKE_CASE      							=       """mbcs"""
      # Flush the keyboard buffer
      while msvcrt.kbhit():
         msvcrt.getch()
      if len(UpperCamelCase__      ) == 0:
         # Read the keystroke
         __SCREAMING_SNAKE_CASE      							=       msvcrt.getch()

         # If it is a prefix char, get second part
         if ch in (b"\x00", b"\xe0"):
            __SCREAMING_SNAKE_CASE      							=       ch + msvcrt.getch()
            # Translate actual Win chars to bullet char types
            try:
               __SCREAMING_SNAKE_CASE      							=       chr(WIN_KEYMAP[cha]      )
               WIN_CH_BUFFER.append(chr(KEYMAP["""mod_int"""]      )      )
               WIN_CH_BUFFER.append(UpperCamelCase__      )
               if ord(UpperCamelCase__      ) in (
                   KEYMAP["insert"] - 1 << 9,
                   KEYMAP["delete"] - 1 << 9,
                   KEYMAP["pg_up"] - 1 << 9,
                   KEYMAP["pg_down"] - 1 << 9,
               ):
                  WIN_CH_BUFFER.append(chr(126      )      )
               __SCREAMING_SNAKE_CASE      							=       chr(KEYMAP["""esc"""]      )
            except KeyError:
               __SCREAMING_SNAKE_CASE      							=       cha[1]
         else:
            __SCREAMING_SNAKE_CASE      							=       ch.decode(UpperCamelCase__      )
      else:
         __SCREAMING_SNAKE_CASE      							=       WIN_CH_BUFFER.pop(0      )
   elif os.name == "posix":
      import termios
      import tty

      __SCREAMING_SNAKE_CASE      							=       sys.stdin.fileno()
      __SCREAMING_SNAKE_CASE      							=       termios.tcgetattr(UpperCamelCase__      )
      try:
         tty.setraw(UpperCamelCase__      )
         __SCREAMING_SNAKE_CASE      							=       sys.stdin.read(1      )
      finally:
         termios.tcsetattr(UpperCamelCase__							,	termios.TCSADRAIN							,	UpperCamelCase__      )
   return ch







def 						__magic_name__       (							)						->					Dict:

   '''simple docstring'''







   __SCREAMING_SNAKE_CASE      							=       get_raw_chars()
   if ord(UpperCamelCase__      ) in [KEYMAP["interrupt"], KEYMAP["newline"]]:
      return char

   elif ord(UpperCamelCase__      ) == KEYMAP["esc"]:
      __SCREAMING_SNAKE_CASE      							=       get_raw_chars()
      if ord(UpperCamelCase__      ) == KEYMAP["mod_int"]:
         __SCREAMING_SNAKE_CASE      							=       get_raw_chars()
         if ord(UpperCamelCase__      ) >= KEYMAP["arrow_begin"] - ARROW_KEY_FLAG and ord(UpperCamelCase__      ) <= KEYMAP["arrow_end"] - ARROW_KEY_FLAG:
            return chr(ord(UpperCamelCase__      ) + ARROW_KEY_FLAG      )
         else:
            return KEYMAP["undefined"]
      else:
         return get_raw_chars()

   else:
      if char in string.printable:
         return char
      else:
         return KEYMAP["undefined"]












'''simple docstring'''

import timeit

import numpy as np

import datasets
from datasets.arrow_writer import ArrowWriter
from datasets.features.features import _ArrayXD

def 						__magic_name__       (							__UpperCAmelCase      )						->					Tuple:

   '''simple docstring'''







   def wrapper(*__UpperCAmelCase							,	**__UpperCAmelCase      ):
      __SCREAMING_SNAKE_CASE      							=       timeit.default_timer()
      __SCREAMING_SNAKE_CASE      							=       func(*__UpperCAmelCase							,	**__UpperCAmelCase      )
      __SCREAMING_SNAKE_CASE      							=       timeit.default_timer() - starttime
      return delta

   __SCREAMING_SNAKE_CASE      							=       func.__name__

   return wrapper

def 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase=100							,	__UpperCAmelCase=None      )						->					Optional[Any]:

   '''simple docstring'''







   __SCREAMING_SNAKE_CASE      							=       []
   __SCREAMING_SNAKE_CASE      							=       seq_shapes or {}
   for i in range(__UpperCAmelCase      ):
      __SCREAMING_SNAKE_CASE      							=       {}
      for col_id, (k, v) in enumerate(features.items()      ):
         if isinstance(__UpperCAmelCase							,	_ArrayXD      ):
            __SCREAMING_SNAKE_CASE      							=       np.random.rand(*v.shape      ).astype(v.dtype      )
         elif isinstance(__UpperCAmelCase							,	datasets.Value      ):
            if v.dtype == "string":
               __SCREAMING_SNAKE_CASE      							=       """The small grey turtle was surprisingly fast when challenged."""
            else:
               __SCREAMING_SNAKE_CASE      							=       np.random.randint(10							,	size=1      ).astype(v.dtype      ).item()
         elif isinstance(__UpperCAmelCase							,	datasets.Sequence      ):
            while isinstance(__UpperCAmelCase							,	datasets.Sequence      ):
               __SCREAMING_SNAKE_CASE      							=       v.feature
            __SCREAMING_SNAKE_CASE      							=       seq_shapes[k]
            __SCREAMING_SNAKE_CASE      							=       np.random.rand(*__UpperCAmelCase      ).astype(v.dtype      )
         __SCREAMING_SNAKE_CASE      							=       data

      dummy_data.append((i, example)      )

   return dummy_data







def 						__magic_name__       (							__UpperCAmelCase							,	__UpperCAmelCase							,	__UpperCAmelCase=100							,	__UpperCAmelCase=None      )						->					str:

   '''simple docstring'''







   __SCREAMING_SNAKE_CASE      							=       generate_examples(__UpperCAmelCase							,	num_examples=__UpperCAmelCase							,	seq_shapes=__UpperCAmelCase      )

   with ArrowWriter(features=__UpperCAmelCase							,	path=__UpperCAmelCase      ) as writer:
      for key, record in dummy_data:
         __SCREAMING_SNAKE_CASE      							=       features.encode_example(__UpperCAmelCase      )
         writer.write(__UpperCAmelCase      )

      __SCREAMING_SNAKE_CASE							,     __SCREAMING_SNAKE_CASE      							=       writer.finalize()

   if not num_final_examples == num_examples:
      raise ValueError(
          f"""Error writing the dataset, wrote {num_final_examples} examples but should have written {num_examples}."""      )

   __SCREAMING_SNAKE_CASE      							=       datasets.Dataset.from_file(filename=__UpperCAmelCase							,	info=datasets.DatasetInfo(features=__UpperCAmelCase      )      )

   return dataset





