



'''simple docstring'''

import json
import os
import tempfile

import datasets
from utils import generate_example_dataset, get_duration


UpperCAmelCase      						=       5_0000
UpperCAmelCase      						=       5000

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






@get_duration
def 						_snake_case						(   _SCREAMING_SNAKE_CASE	:		int				,						_SCREAMING_SNAKE_CASE	:		Tuple				)     ->		Tuple:







	"""simple docstring"""
	for i in range(_lowerCAmelCase				):
		lowerCAmelCase       =      dataset[i]






@get_duration
def 						_snake_case						(   _SCREAMING_SNAKE_CASE	:		int				,						_SCREAMING_SNAKE_CASE	:		Optional[Any]				,						_SCREAMING_SNAKE_CASE	:		str				)     ->		Dict:







	"""simple docstring"""
	for i in range(0				,						len(_lowerCAmelCase				)				,						_lowerCAmelCase				):
		lowerCAmelCase       =      dataset[i : i + batch_size]






@get_duration
def 						_snake_case						(   _SCREAMING_SNAKE_CASE	:		str				,						_SCREAMING_SNAKE_CASE	:		Optional[Any]				,						_SCREAMING_SNAKE_CASE	:		Any				)     ->		int:







	"""simple docstring"""
	with dataset.formatted_as(type=_lowerCAmelCase				):
		for i in range(_lowerCAmelCase				):
			lowerCAmelCase       =      dataset[i]






@get_duration
def 						_snake_case						(   _SCREAMING_SNAKE_CASE	:		List[Any]				,						_SCREAMING_SNAKE_CASE	:		Dict				,						_SCREAMING_SNAKE_CASE	:		Any				,						_SCREAMING_SNAKE_CASE	:		Tuple				)     ->		Dict:







	"""simple docstring"""
	with dataset.formatted_as(type=_lowerCAmelCase				):
		for i in range(0				,						_lowerCAmelCase				,						_lowerCAmelCase				):
			lowerCAmelCase       =      dataset[i : i + batch_size]






def 						_snake_case						(   )     ->		int:







	"""simple docstring"""
	lowerCAmelCase       =      {"num examples": SPEED_TEST_N_EXAMPLES}
	lowerCAmelCase       =      [
	    (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}),
	]

	lowerCAmelCase       =      [
	    (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"""				)
		lowerCAmelCase       =      datasets.Features(
		    {"""list""": datasets.Sequence(datasets.Value("""float32"""				)				), """numbers""": datasets.Value("""float32"""				)}				)
		lowerCAmelCase       =      generate_example_dataset(
		    os.path.join(_lowerCAmelCase				,						"""dataset.arrow"""				)				,						_lowerCAmelCase				,						num_examples=_lowerCAmelCase				,						seq_shapes={"""list""": (100,)}				,						)
		print("""first set of iterations"""				)
		for func, kwargs in functions:
			print(func.__name__				,						str(_lowerCAmelCase				)				)
			lowerCAmelCase       =      func(_lowerCAmelCase				,						**_lowerCAmelCase				)

		print("""shuffling dataset"""				)
		lowerCAmelCase       =      dataset.shuffle()
		print("""Second set of iterations (after shuffling"""				)
		for func, kwargs in functions_shuffled:
			print("""shuffled """				,						func.__name__				,						str(_lowerCAmelCase				)				)
			lowerCAmelCase       =      func(
			    _lowerCAmelCase				,						**_lowerCAmelCase				)

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


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






def 						A_							(	_lowerCAmelCase = 1000	)		->					int:
 UpperCamelCase      :   Optional[int]			      =  -1
 UpperCamelCase      :   int			      =  0
 for a in range(1				,  n // 3	):
  # Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c
  UpperCamelCase      :   Optional[Any]			      =  (n * n - 2 * a * n) // (2 * n - 2 * a)
  UpperCamelCase      :   List[str]			      =  n - a - b
  if c * c == (a * a + b * b):
   UpperCamelCase      :   Union[str, Any]			      =  a * b * c
   if candidate >= product:
    UpperCamelCase      :   Tuple			      =  candidate
 return product


if __name__ == "__main__":
    print(f"""{solution() = }""")
