

import timeit

import numpy as np

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

def       a__					(		UpperCAmelCase							:      int      )  ->						str:
  def wrapper(*UpperCAmelCase							:      List[str]    ,			**UpperCAmelCase							:      Optional[Any]      ):
    UpperCAmelCase	:							str						=			timeit.default_timer()
    UpperCAmelCase	:							List[Any]						=			func(*__lowerCAmelCase    ,			**__lowerCAmelCase      )
    UpperCAmelCase	:							Any						=			timeit.default_timer() - starttime
    return delta

  UpperCAmelCase	:							Optional[int]						=			func.__name__

  return wrapper

def       a__					(		UpperCAmelCase							:      Union[str, Any]    ,			UpperCAmelCase							:      str=100    ,			UpperCAmelCase							:      Optional[int]=None      )  ->						int:
  UpperCAmelCase	:							List[str]						=			[]
  UpperCAmelCase	:							Dict						=			seq_shapes or {}
  for i in range(__lowerCAmelCase      ):
    UpperCAmelCase	:							Optional[Any]						=			{}
    for col_id, (k, v) in enumerate(features.items()      ):
      if isinstance(__lowerCAmelCase    ,			_ArrayXD      ):
        UpperCAmelCase	:							Dict						=			np.random.rand(*v.shape      ).astype(v.dtype      )
      elif isinstance(__lowerCAmelCase    ,			datasets.Value      ):
        if v.dtype == "string":
          UpperCAmelCase	:							Optional[int]						=			"""The small grey turtle was surprisingly fast when challenged."""
        else:
          UpperCAmelCase	:							List[str]						=			np.random.randint(10    ,			size=1      ).astype(v.dtype      ).item()
      elif isinstance(__lowerCAmelCase    ,			datasets.Sequence      ):
        while isinstance(__lowerCAmelCase    ,			datasets.Sequence      ):
          UpperCAmelCase	:							Optional[Any]						=			v.feature
        UpperCAmelCase	:							str						=			seq_shapes[k]
        UpperCAmelCase	:							List[str]						=			np.random.rand(*__lowerCAmelCase      ).astype(v.dtype      )
      UpperCAmelCase	:							Any						=			data

    dummy_data.append((i, example)      )

  return dummy_data






def       a__					(		UpperCAmelCase							:      str    ,			UpperCAmelCase							:      Optional[int]    ,			UpperCAmelCase							:      Optional[Any]=100    ,			UpperCAmelCase							:      Dict=None      )  ->						str:
  UpperCAmelCase	:							Tuple						=			generate_examples(__lowerCAmelCase    ,			num_examples=__lowerCAmelCase    ,			seq_shapes=__lowerCAmelCase      )

  with ArrowWriter(features=__lowerCAmelCase    ,			path=__lowerCAmelCase      ) as writer:
    for key, record in dummy_data:
      UpperCAmelCase	:							List[str]						=			features.encode_example(__lowerCAmelCase      )
      writer.write(__lowerCAmelCase      )

    UpperCAmelCase	:							Optional[int]						=			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}.'''      )

  UpperCAmelCase	:							Optional[int]						=			datasets.Dataset.from_file(filename=__lowerCAmelCase    ,			info=datasets.DatasetInfo(features=__lowerCAmelCase      )      )

  return dataset








def       a__					(		UpperCAmelCase							:      int    ,			UpperCAmelCase							:      int      )  ->						str:
  if a < 0 or b < 0:
    raise ValueError('''the value of both inputs must be positive'''      )
  UpperCAmelCase	:							List[Any]						=			str(bin(UpperCAmelCase      )      )[2:]  # remove the leading "0b"
  UpperCAmelCase	:							List[str]						=			str(bin(UpperCAmelCase      )      )[2:]
  UpperCAmelCase	:							Optional[Any]						=			max(len(UpperCAmelCase      )    ,			len(UpperCAmelCase      )      )
  return "0b" + "".join(
      str(int('''1''' in (char_a, char_b)      )      )
      for char_a, char_b in zip(a_binary.zfill(UpperCAmelCase      )    ,			b_binary.zfill(UpperCAmelCase      )      )      )


if __name__ == "__main__":
     import doctest

     doctest.testmod()





