

'''simple docstring'''



import json
import os
import tempfile

import datasets
from utils import generate_example_dataset, get_duration


__snake_case			:     Union[str, Any]										=      5_0000
__snake_case			:     Optional[Any]										=      5000

__snake_case						,       __snake_case			:     Union[str, Any]										=      os.path.split(__file__)
__snake_case			:     Tuple										=      os.path.join(RESULTS_BASEPATH, 'results', RESULTS_FILENAME.replace('.py', '.json'))
@get_duration
def 						__lowerCamelCase	(       __snake_case					:		datasets.Dataset,		__snake_case					:		List[Any]	)	->							Optional[int]:






						"""simple docstring"""





						for i in range(__snake_case	):
												A__					:       Dict     =dataset[i]
@get_duration
def 						__lowerCamelCase	(       __snake_case					:		datasets.Dataset,		__snake_case					:		Dict,		__snake_case					:		Dict	)	->							Optional[Any]:






						"""simple docstring"""





						for i in range(0,		len(__snake_case	),		__snake_case	):
												A__					:       Optional[Any]     =dataset[i : i + batch_size]
@get_duration
def 						__lowerCamelCase	(       __snake_case					:		datasets.Dataset,		__snake_case					:		List[str],		__snake_case					:		Optional[Any]	)	->							List[str]:






						"""simple docstring"""





						with dataset.formatted_as(type=__snake_case	):
												for i in range(__snake_case	):
																		A__					:       Dict     =dataset[i]
@get_duration
def 						__lowerCamelCase	(       __snake_case					:		datasets.Dataset,		__snake_case					:		Dict,		__snake_case					:		Union[str, Any],		__snake_case					:		List[str]	)	->							Tuple:






						"""simple docstring"""





						with dataset.formatted_as(type=__snake_case	):
												for i in range(0,		__snake_case,		__snake_case	):
																		A__					:       Optional[int]     =dataset[i : i + batch_size]
def 						__lowerCamelCase	(       )	->							Dict:






						"""simple docstring"""





						A__					:       Dict     ={"""num examples""": SPEED_TEST_N_EXAMPLES}
						A__					:       List[str]     =[
						    (read, {"""length""": SMALL_TEST}),
						    (read, {"""length""": SPEED_TEST_N_EXAMPLES}),
						    (read_batch, {"""length""": SPEED_TEST_N_EXAMPLES, """batch_size""": 10}),
						    (read_batch, {"""length""": SPEED_TEST_N_EXAMPLES, """batch_size""": 100}),
						    (read_batch, {"""length""": SPEED_TEST_N_EXAMPLES, """batch_size""": 1_000}),
						    (read_formatted, {"""type""": """numpy""", """length""": SMALL_TEST}),
						    (read_formatted, {"""type""": """pandas""", """length""": SMALL_TEST}),
						    (read_formatted, {"""type""": """torch""", """length""": SMALL_TEST}),
						    (read_formatted, {"""type""": """tensorflow""", """length""": SMALL_TEST}),
						    (read_formatted_batch, {"""type""": """numpy""", """length""": SMALL_TEST, """batch_size""": 10}),
						    (read_formatted_batch, {"""type""": """numpy""", """length""": SMALL_TEST, """batch_size""": 1_000}),
						]

						A__					:       List[str]     =[
						    (read, {"""length""": SMALL_TEST}),
						    (read, {"""length""": SPEED_TEST_N_EXAMPLES}),
						    (read_batch, {"""length""": SPEED_TEST_N_EXAMPLES, """batch_size""": 10}),
						    (read_batch, {"""length""": SPEED_TEST_N_EXAMPLES, """batch_size""": 100}),
						    (read_batch, {"""length""": SPEED_TEST_N_EXAMPLES, """batch_size""": 1_000}),
						    (read_formatted, {"""type""": """numpy""", """length""": SMALL_TEST}),
						    (read_formatted_batch, {"""type""": """numpy""", """length""": SMALL_TEST, """batch_size""": 10}),
						    (read_formatted_batch, {"""type""": """numpy""", """length""": SMALL_TEST, """batch_size""": 1_000}),
						]
						with tempfile.TemporaryDirectory() as tmp_dir:
												print("""generating dataset"""	)
												A__					:       int     =datasets.Features(
												    {"""list""": datasets.Sequence(datasets.Value("""float32"""	)	), """numbers""": datasets.Value("""float32"""	)}	)
												A__					:       List[str]     =generate_example_dataset(
												    os.path.join(__snake_case,		"""dataset.arrow"""	),		__snake_case,		num_examples=__snake_case,		seq_shapes={"""list""": (100,)},		)
												print("""first set of iterations"""	)
												for func, kwargs in functions:
																		print(func.__name__,		str(__snake_case	)	)
																		A__					:       str     =func(__snake_case,		**__snake_case	)

												print("""shuffling dataset"""	)
												A__					:       List[str]     =dataset.shuffle()
												print("""Second set of iterations (after shuffling"""	)
												for func, kwargs in functions_shuffled:
																		print("""shuffled """,		func.__name__,		str(__snake_case	)	)
																		A__					:       int     =func(
																		    __snake_case,		**__snake_case	)

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


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




'''simple docstring'''



def 						__lowerCamelCase	(       __snake_case					:		int	)	->							bool:






						"""simple docstring"""





						if p < 2:
												raise ValueError("""p should not be less than 2!"""	)
						elif p == 2:
												return True

						A__					:       Any     =4
						A__					:       int     =(1 << p) - 1
						for _ in range(p - 2	):
												A__					:       Dict     =((s * s) - 2) % m
						return s == 0


if __name__ == "__main__":
		print(lucas_lehmer_test(7))
		print(lucas_lehmer_test(11))

