import json
import os
import tempfile

import datasets
from utils import generate_example_dataset, get_duration


_UpperCamelCase				:		Dict       			=		50_00_00

_UpperCamelCase				:		Optional[int]       			=		os.path.split(__file__)
_UpperCamelCase				:		Optional[Any]       			=		os.path.join(RESULTS_BASEPATH, 'results', RESULTS_FILENAME.replace('.py', '.json'))



@get_duration
def 						__snake_case (       lowerCAmelCase       :     Any			):
 __UpperCAmelCase         =					dataset.select(range(0      ,  len(_UpperCAmelCase			)      ,  2			)			)



@get_duration
def 						__snake_case (       lowerCAmelCase       :     Any			):
 __UpperCAmelCase         =					dataset.sort('numbers'			)



@get_duration
def 						__snake_case (       lowerCAmelCase       :     int			):
 __UpperCAmelCase         =					dataset.shuffle()



@get_duration
def 						__snake_case (       lowerCAmelCase       :     Dict			):
 __UpperCAmelCase         =					dataset.train_test_split(0.1			)



@get_duration
def 						__snake_case (       lowerCAmelCase       :     Union[str, Any]      ,  lowerCAmelCase       :     int=10			):






 for shard_id in range(_UpperCAmelCase			):
  __UpperCAmelCase         =					dataset.shard(_UpperCAmelCase      ,  _UpperCAmelCase			)



def 						__snake_case (       ):
 __UpperCAmelCase         =					{'num examples': SPEED_TEST_N_EXAMPLES}
 __UpperCAmelCase         =					(select, sort, shuffle, train_test_split, shard)
 with tempfile.TemporaryDirectory() as tmp_dir:
  print('generating dataset'			)
  __UpperCAmelCase         =					datasets.Features({'text': datasets.Value('string'			), 'numbers': datasets.Value('float32'			)}			)
  __UpperCAmelCase         =					generate_example_dataset(
      os.path.join(_UpperCAmelCase      ,  'dataset.arrow'			)      ,  _UpperCAmelCase      ,  num_examples=_UpperCAmelCase			)
  print('Functions'			)
  for func in functions:
   print(func.__name__			)
   __UpperCAmelCase         =					func(_UpperCAmelCase			)

 with open(_UpperCAmelCase      ,  'wb'			) as f:
  f.write(json.dumps(_UpperCAmelCase			).encode('utf-8'			)			)


if __name__ == "__main__":  # useful to run the profiler
     benchmark_indices_mapping()




'''simple docstring'''




def 						__snake_case (       lowerCAmelCase       :     str			):
 __UpperCAmelCase         =					5381
 for x in s:
  __UpperCAmelCase         =					((hash_value << 5) + hash_value) + ord(lowerCAmelCase			)
 return hash_value & 0Xffff_ffff



