code: 
  
  
  import json
  import os
  import tempfile
  
  import datasets
  from datasets.arrow_writer import ArrowWriter
  from datasets.features import ArrayaD
  from utils import generate_examples, get_duration
  
  
  __a   				=      (30, 4_87)
  __a   				=      (36, 10_24)
  __a   				=      (1_00, 1_00)
  __a   				=      1_00
  
  __a   				=      datasets.Features(
      {'''text''': ArrayaD(SHAPE_TEST_1, dtype='''float32'''), '''image''': ArrayaD(SHAPE_TEST_2, dtype='''float32''')}
  )
  
  __a				,      __a   				=      os.path.split(__file__)
  __a   				=      os.path.join(RESULTS_BASEPATH, '''results''', RESULTS_FILENAME.replace('''.py''', '''.json'''))
  
  
  
  
  @get_duration
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase     )    ->List[Any]:
  
  
  
  
  
  
  
  						"""simple docstring"""
  
  						with ArrowWriter(features=_UpperCamelCase,    path=os.path.join(_UpperCamelCase,    '''beta.arrow'''     )     ) as writer:
  												for key, record in dummy_data:
  																		lowercase			:   Tuple					   =		my_features.encode_example(_UpperCamelCase     )
  																		writer.write(_UpperCamelCase     )
  												lowercase			:   List[Any]					   =		writer.finalize()
  
  
  
  
  @get_duration
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase     )    ->List[str]:
  
  
  
  
  
  
  
  						"""simple docstring"""
  
  						lowercase			:   List[str]					   =		datasets.Dataset.from_file(
  						    filename=os.path.join(_UpperCamelCase,    '''beta.arrow'''     ),    info=datasets.DatasetInfo(features=_UpperCamelCase     )     )
  						for _ in dataset:
  												pass
  
  
  
  
  @get_duration
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase     )    ->Optional[int]:
  
  
  
  
  
  
  
  						"""simple docstring"""
  
  						lowercase			:   Dict					   =		datasets.Dataset.from_file(
  						    filename=os.path.join(_UpperCamelCase,    '''beta.arrow'''     ),    info=datasets.DatasetInfo(features=_UpperCamelCase     )     )
  						dataset.set_format('''numpy'''     )
  						for _ in dataset:
  												pass
  
  
  
  
  @get_duration
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase     )    ->Tuple:
  
  
  
  
  
  
  
  						"""simple docstring"""
  
  						lowercase			:   Optional[int]					   =		10
  						lowercase			:   List[Any]					   =		datasets.Dataset.from_file(
  						    filename=os.path.join(_UpperCamelCase,    '''beta.arrow'''     ),    info=datasets.DatasetInfo(features=_UpperCamelCase     )     )
  						for i in range(0,    len(_UpperCamelCase     ),    _UpperCamelCase     ):
  												lowercase			:   int					   =		dataset[i : i + batch_size]
  
  
  
  
  @get_duration
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase     )    ->Union[str, Any]:
  
  
  
  
  
  
  
  						"""simple docstring"""
  
  						lowercase			:   Optional[int]					   =		10
  						lowercase			:   List[str]					   =		datasets.Dataset.from_file(
  						    filename=os.path.join(_UpperCamelCase,    '''beta.arrow'''     ),    info=datasets.DatasetInfo(features=_UpperCamelCase     )     )
  						dataset.set_format('''numpy'''     )
  						for i in range(0,    len(_UpperCamelCase     ),    _UpperCamelCase     ):
  												lowercase			:   Dict					   =		dataset[i : i + batch_size]
  
  
  
  
  @get_duration
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase     )    ->int:
  
  
  
  
  
  
  
  						"""simple docstring"""
  
  						lowercase			:   Any					   =		datasets.Dataset.from_file(
  						    filename=os.path.join(_UpperCamelCase,    '''beta.arrow'''     ),    info=datasets.DatasetInfo(features=_UpperCamelCase     )     )
  						for col in feats:
  												lowercase			:   Optional[int]					   =		dataset[col]
  
  
  
  
  @get_duration
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase     )    ->Optional[Any]:
  
  
  
  
  
  
  
  						"""simple docstring"""
  
  						lowercase			:   Any					   =		datasets.Dataset.from_file(
  						    filename=os.path.join(_UpperCamelCase,    '''beta.arrow'''     ),    info=datasets.DatasetInfo(features=_UpperCamelCase     )     )
  						dataset.set_format('''numpy'''     )
  						for col in feats:
  												lowercase			:   Dict					   =		dataset[col]
  
  
  
  
  def 			__lowercase	(						)    ->Dict:
  
  
  
  
  
  
  
  						"""simple docstring"""
  
  						lowercase			:   Union[str, Any]					   =		{}
  						lowercase			:   Dict					   =		(
  						    read_unformated,
  						    read_formatted_as_numpy,
  						    read_batch_unformated,
  						    read_batch_formatted_as_numpy,
  						    read_col_unformated,
  						    read_col_formatted_as_numpy,
  						)
  						with tempfile.TemporaryDirectory() as tmp_dir:
  												lowercase			:   str					   =		datasets.Features({'''image''': ArrayaD(_UpperCamelCase,    dtype='''float32'''     )}     )
  												lowercase			:   List[Any]					   =		generate_examples(features=_UpperCamelCase,    num_examples=_UpperCamelCase     )
  												lowercase			:   List[str]					   =		write(_UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase     )
  												for read_func in read_functions:
  																		lowercase			:   Dict					   =		read_func(_UpperCamelCase,    _UpperCamelCase     )
  
  						with tempfile.TemporaryDirectory() as tmp_dir:
  												# don't use fixed length for fair comparison
  												# feats = datasets.Features(
  												#     {"image": datasets.Sequence(datasets.Sequence(datasets.Value("float32"), SPEED_TEST_SHAPE[1]), SPEED_TEST_SHAPE[0])}
  												# )
  												lowercase			:   Optional[Any]					   =		datasets.Features({'''image''': datasets.Sequence(datasets.Sequence(datasets.Value('''float32'''     )     )     )}     )
  												lowercase			:   Optional[int]					   =		generate_examples(
  												    features=_UpperCamelCase,    num_examples=_UpperCamelCase,    seq_shapes={'''image''': SPEED_TEST_SHAPE}     )
  												lowercase			:   Any					   =		write(_UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase     )
  												for read_func in read_functions:
  																		lowercase			:   Union[str, Any]					   =		read_func(_UpperCamelCase,    _UpperCamelCase     )
  
  						with tempfile.TemporaryDirectory() as tmp_dir:
  												# don't use fixed length for fair comparison
  												# feats = datasets.Features(
  												#     {"image": datasets.Sequence(datasets.Value("float32"), SPEED_TEST_SHAPE[0] * SPEED_TEST_SHAPE[1])}
  												# )
  												lowercase			:   Optional[Any]					   =		datasets.Features({'''image''': datasets.Sequence(datasets.Value('''float32'''     )     )}     )
  												lowercase			:   Optional[int]					   =		generate_examples(
  												    features=_UpperCamelCase,    num_examples=_UpperCamelCase,    seq_shapes={'''image''': [SPEED_TEST_SHAPE[0] * SPEED_TEST_SHAPE[1]]},    )
  												lowercase			:   int					   =		write(_UpperCamelCase,    _UpperCamelCase,    _UpperCamelCase     )
  												for read_func in read_functions:
  																		lowercase			:   List[Any]					   =		read_func(_UpperCamelCase,    _UpperCamelCase     )
  
  						with open(_UpperCamelCase,    '''wb'''     ) as f:
  												f.write(json.dumps(_UpperCamelCase     ).encode('''utf-8'''     )     )
  
  
  if __name__ == "__main__":  # useful to run the profiler
  		benchmark_array_xd()
  
  
style_context: 
  
  
  import numpy as np
  
  
  
  
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase     )    ->Dict:
  
  
  
  
  
  
  
        """simple docstring"""
  
        lowercase			:   Optional[Any]					   =		np.array(_UpperCamelCase     )
        lowercase			:   Dict					   =		np.array(_UpperCamelCase     )
  
        lowercase			:   List[Any]					   =		abs(predict - actual     )
        lowercase			:   int					   =		difference.mean()
  
        return score
  
  
  
  
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase     )    ->List[Any]:
  
  
  
  
  
  
  
        """simple docstring"""
  
        lowercase			:   Tuple					   =		np.array(_UpperCamelCase     )
        lowercase			:   str					   =		np.array(_UpperCamelCase     )
  
        lowercase			:   List[str]					   =		predict - actual
        lowercase			:   Tuple					   =		np.square(_UpperCamelCase     )
  
        lowercase			:   Union[str, Any]					   =		square_diff.mean()
        return score
  
  
  
  
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase     )    ->str:
  
  
  
  
  
  
  
        """simple docstring"""
  
        lowercase			:   Union[str, Any]					   =		np.array(_UpperCamelCase     )
        lowercase			:   Optional[Any]					   =		np.array(_UpperCamelCase     )
  
        lowercase			:   Tuple					   =		predict - actual
        lowercase			:   Dict					   =		np.square(_UpperCamelCase     )
        lowercase			:   Union[str, Any]					   =		square_diff.mean()
        lowercase			:   Union[str, Any]					   =		np.sqrt(_UpperCamelCase     )
        return score
  
  
  
  
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase     )    ->List[Any]:
  
  
  
  
  
  
  
        """simple docstring"""
  
        lowercase			:   List[str]					   =		np.array(_UpperCamelCase     )
        lowercase			:   List[Any]					   =		np.array(_UpperCamelCase     )
  
        lowercase			:   Dict					   =		np.log(predict + 1     )
        lowercase			:   List[str]					   =		np.log(actual + 1     )
  
        lowercase			:   int					   =		log_predict - log_actual
        lowercase			:   Tuple					   =		np.square(_UpperCamelCase     )
        lowercase			:   List[Any]					   =		square_diff.mean()
  
        lowercase			:   int					   =		np.sqrt(_UpperCamelCase     )
  
        return score
  
  
  
  
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase     )    ->List[str]:
  
  
  
  
  
  
  
        """simple docstring"""
  
        lowercase			:   List[Any]					   =		np.array(_UpperCamelCase     )
        lowercase			:   Optional[int]					   =		np.array(_UpperCamelCase     )
  
        lowercase			:   Optional[int]					   =		predict - actual
        lowercase			:   Optional[int]					   =		np.sum(_UpperCamelCase     ) / len(_UpperCamelCase     )
        lowercase			:   Dict					   =		np.sum(_UpperCamelCase     ) / len(_UpperCamelCase     )
        # print(numerator, denumerator)
        lowercase			:   int					   =		float(_UpperCamelCase     ) / denumerator * 100
  
        return score
  
  
  
  
  def 			__lowercase	(						_UpperCamelCase,    _UpperCamelCase     )    ->List[Any]:
  
  
  
  
  
  
  
        """simple docstring"""
  
        return np.mean(np.array(_UpperCamelCase     ) == np.array(_UpperCamelCase     )     )
  
  