


import json
import os
import tempfile

import datasets
from utils import generate_example_dataset, get_duration


__magic_name__       					=      5_0_0_0_0_0

__magic_name__					,      __magic_name__       					=      os.path.split(__file__)
__magic_name__       					=      os.path.join(RESULTS_BASEPATH, '''results''', RESULTS_FILENAME.replace('''.py''', '''.json'''))







@get_duration
def     __magic_name__  (      lowerCAmelCase_):
	'''simple docstring'''


	lowerCamelCase_			:							Dict      =       dataset.select(range(0      ,					len(lowerCAmelCase_)      ,					2))







@get_duration
def     __magic_name__  (      lowerCAmelCase_):
	'''simple docstring'''


	lowerCamelCase_			:							List[Any]      =       dataset.sort("numbers")







@get_duration
def     __magic_name__  (      lowerCAmelCase_):
	'''simple docstring'''


	lowerCamelCase_			:							int      =       dataset.shuffle()







@get_duration
def     __magic_name__  (      lowerCAmelCase_):
	'''simple docstring'''


	lowerCamelCase_			:							Any      =       dataset.train_test_split(0.1)







@get_duration
def     __magic_name__  (      lowerCAmelCase_      ,					lowerCAmelCase_=10):
	'''simple docstring'''


	for shard_id in range(lowerCAmelCase_):
		lowerCamelCase_			:							int      =       dataset.shard(lowerCAmelCase_      ,					lowerCAmelCase_)







def     __magic_name__  (      ):
	'''simple docstring'''


	lowerCamelCase_			:							Union[str, Any]      =       {"num examples": SPEED_TEST_N_EXAMPLES}
	lowerCamelCase_			:							Optional[int]      =       (select, sort, shuffle, train_test_split, shard)
	with tempfile.TemporaryDirectory() as tmp_dir:
		print("generating dataset")
		lowerCamelCase_			:							Dict      =       datasets.Features({"text": datasets.Value("string"), "numbers": datasets.Value("float32")})
		lowerCamelCase_			:							Tuple      =       generate_example_dataset(
		    os.path.join(lowerCAmelCase_      ,					"dataset.arrow")      ,					lowerCAmelCase_      ,					num_examples=lowerCAmelCase_)
		print("Functions")
		for func in functions:
			print(func.__name__)
			lowerCamelCase_			:							Any      =       func(lowerCAmelCase_)

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


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





def     __magic_name__  (      lowerCAmelCase_      ,					lowerCAmelCase_):
	'''simple docstring'''


	lowerCamelCase_			:							Union[str, Any]      =       0
	for ele in arr:
		total_sum += product_sum(lowerCAmelCase_      ,					depth + 1) if isinstance(lowerCAmelCase_      ,					lowerCAmelCase_) else ele
	return total_sum * depth







def     __magic_name__  (      lowerCAmelCase_):
	'''simple docstring'''


	return product_sum(lowerCAmelCase_      ,					1)


if __name__ == "__main__":
							import doctest

							doctest.testmod()

