





import json
import os
import tempfile

import datasets
from utils import generate_example_dataset, get_duration


__UpperCAmelCase						=      50_00_00

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


@get_duration
def 			__UpperCamelCase				(			lowercase__	:       datasets.Dataset		)	->      Union[str, Any]:
    '''simple docstring'''





    lowerCAmelCase_					:	List[str]						=   dataset.select(range(0		,    len(lowercase__		)		,    2		)		)


@get_duration
def 			__UpperCamelCase				(			lowercase__	:       datasets.Dataset		)	->      Dict:
    '''simple docstring'''





    lowerCAmelCase_					:	Tuple						=   dataset.sort("""numbers"""		)


@get_duration
def 			__UpperCamelCase				(			lowercase__	:       datasets.Dataset		)	->      Optional[int]:
    '''simple docstring'''





    lowerCAmelCase_					:	Dict						=   dataset.shuffle()


@get_duration
def 			__UpperCamelCase				(			lowercase__	:       datasets.Dataset		)	->      Union[str, Any]:
    '''simple docstring'''





    lowerCAmelCase_					:	List[Any]						=   dataset.train_test_split(0.1		)


@get_duration
def 			__UpperCamelCase				(			lowercase__	:       datasets.Dataset		,    lowercase__	:       Any=10		)	->      Dict:
    '''simple docstring'''





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


def 			__UpperCamelCase				(			)	->      Union[str, Any]:
    '''simple docstring'''





    lowerCAmelCase_					:	int						=   {"""num examples""": SPEED_TEST_N_EXAMPLES}
    lowerCAmelCase_					:	List[Any]						=   (select, sort, shuffle, train_test_split, shard)
    with tempfile.TemporaryDirectory() as tmp_dir:
        print("""generating dataset"""		)
        lowerCAmelCase_					:	Any						=   datasets.Features({"""text""": datasets.Value("""string"""		), """numbers""": datasets.Value("""float32"""		)}		)
        lowerCAmelCase_					:	int						=   generate_example_dataset(
            os.path.join(lowercase__		,    """dataset.arrow"""		)		,    lowercase__		,    num_examples=lowercase__		)
        print("""Functions"""		)
        for func in functions:
            print(func.__name__		)
            lowerCAmelCase_					:	int						=   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()









def 			__UpperCamelCase				(			lowercase__	:       set		,    lowercase__	:       set		)	->      set:
    '''simple docstring'''





    assert isinstance(lowercase__		,    lowercase__		), f'The input value of [set_a={set_a}] is not a set'
    assert isinstance(lowercase__		,    lowercase__		), f'The input value of [set_b={set_b}] is not a set'

    return {a + b for a in set_a for b in set_b}


if __name__ == "__main__":
  from doctest import testmod

  testmod()


