


import json
import os
import tempfile

import datasets
from utils import generate_example_dataset, get_duration


__SCREAMING_SNAKE_CASE	:							Optional[int]           =  500_000

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

@get_duration
def 		snake_case_   (				lowercase__     :    datasets.Dataset     ):






				'''simple docstring'''






				_lowerCAmelCase  						=dataset.select(range(0       ,     len(lowercase__     )       ,     2     )     )

@get_duration
def 		snake_case_   (				lowercase__     :    datasets.Dataset     ):






				'''simple docstring'''






				_lowerCAmelCase  						=dataset.sort("""numbers"""     )

@get_duration
def 		snake_case_   (				lowercase__     :    datasets.Dataset     ):






				'''simple docstring'''






				_lowerCAmelCase  						=dataset.shuffle()

@get_duration
def 		snake_case_   (				lowercase__     :    datasets.Dataset     ):






				'''simple docstring'''






				_lowerCAmelCase  						=dataset.train_test_split(0.1     )

@get_duration
def 		snake_case_   (				lowercase__     :    datasets.Dataset       ,     lowercase__     :    Tuple=10     ):






				'''simple docstring'''






				for shard_id in range(lowercase__     ):
								_lowerCAmelCase  						=dataset.shard(lowercase__       ,     lowercase__     )

def 		snake_case_   (				):






				'''simple docstring'''






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

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


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





__SCREAMING_SNAKE_CASE	:							Optional[Any]           =  '''
# Transformers installation
! pip install transformers datasets
# To install from source instead of the last release, comment the command above and uncomment the following one.
# ! pip install git+https://github.com/huggingface/transformers.git
'''

__SCREAMING_SNAKE_CASE	:							Optional[int]           =  [{'''type''': '''code''', '''content''': INSTALL_CONTENT}]
__SCREAMING_SNAKE_CASE	:							Optional[int]           =  {
    '''{processor_class}''': '''FakeProcessorClass''',
    '''{model_class}''': '''FakeModelClass''',
    '''{object_class}''': '''FakeObjectClass''',
}

