
'''simple docstring'''

import json
import os
import tempfile

import datasets
from datasets.arrow_writer import ArrowWriter
from datasets.features import ArrayaD
from utils import generate_examples, get_duration


UpperCAmelCase__				:	Union[str, Any]					=						(30, 4_87)
UpperCAmelCase__				:	int					=						(36, 10_24)
UpperCAmelCase__				:	Optional[Any]					=						(1_00, 1_00)
UpperCAmelCase__				:	str					=						1_00

UpperCAmelCase__				:	List[Any]					=						datasets.Features(
    {"text": ArrayaD(SHAPE_TEST_1, dtype="float32"), "image": ArrayaD(SHAPE_TEST_2, dtype="float32")}
)

UpperCAmelCase__		,						UpperCAmelCase__				:	str					=						os.path.split(__file__)
UpperCAmelCase__				:	Optional[Any]					=						os.path.join(RESULTS_BASEPATH, "results", RESULTS_FILENAME.replace(".py", ".json"))







@get_duration
def 					A       ( UpperCamelCase_   :       Dict  ,		UpperCamelCase_   :       Dict  ,		UpperCamelCase_   :       Tuple )   ->    Dict:







			'''simple docstring'''



			with ArrowWriter(features=UpperCamelCase_  ,		path=os.path.join(UpperCamelCase_  ,		"beta.arrow" ) ) as writer:
						for key, record in dummy_data:
									lowerCAmelCase__									=							my_features.encode_example(UpperCamelCase_ )
									writer.write(UpperCamelCase_ )
						lowerCAmelCase__		,lowerCAmelCase__									=							writer.finalize()







@get_duration
def 					A       ( UpperCamelCase_   :       int  ,		UpperCamelCase_   :       Any )   ->    int:







			'''simple docstring'''



			lowerCAmelCase__									=							datasets.Dataset.from_file(
			    filename=os.path.join(UpperCamelCase_  ,		"beta.arrow" )  ,		info=datasets.DatasetInfo(features=UpperCamelCase_ ) )
			for _ in dataset:
						pass







@get_duration
def 					A       ( UpperCamelCase_   :       Tuple  ,		UpperCamelCase_   :       str )   ->    Union[str, Any]:







			'''simple docstring'''



			lowerCAmelCase__									=							datasets.Dataset.from_file(
			    filename=os.path.join(UpperCamelCase_  ,		"beta.arrow" )  ,		info=datasets.DatasetInfo(features=UpperCamelCase_ ) )
			dataset.set_format("numpy" )
			for _ in dataset:
						pass







@get_duration
def 					A       ( UpperCamelCase_   :       int  ,		UpperCamelCase_   :       str )   ->    Optional[Any]:







			'''simple docstring'''



			lowerCAmelCase__									=							10
			lowerCAmelCase__									=							datasets.Dataset.from_file(
			    filename=os.path.join(UpperCamelCase_  ,		"beta.arrow" )  ,		info=datasets.DatasetInfo(features=UpperCamelCase_ ) )
			for i in range(0  ,		len(UpperCamelCase_ )  ,		UpperCamelCase_ ):
						lowerCAmelCase__									=							dataset[i : i + batch_size]







@get_duration
def 					A       ( UpperCamelCase_   :       Dict  ,		UpperCamelCase_   :       str )   ->    str:







			'''simple docstring'''



			lowerCAmelCase__									=							10
			lowerCAmelCase__									=							datasets.Dataset.from_file(
			    filename=os.path.join(UpperCamelCase_  ,		"beta.arrow" )  ,		info=datasets.DatasetInfo(features=UpperCamelCase_ ) )
			dataset.set_format("numpy" )
			for i in range(0  ,		len(UpperCamelCase_ )  ,		UpperCamelCase_ ):
						lowerCAmelCase__									=							dataset[i : i + batch_size]







@get_duration
def 					A       ( UpperCamelCase_   :       Optional[int]  ,		UpperCamelCase_   :       Optional[int] )   ->    int:







			'''simple docstring'''



			lowerCAmelCase__									=							datasets.Dataset.from_file(
			    filename=os.path.join(UpperCamelCase_  ,		"beta.arrow" )  ,		info=datasets.DatasetInfo(features=UpperCamelCase_ ) )
			for col in feats:
						lowerCAmelCase__									=							dataset[col]







@get_duration
def 					A       ( UpperCamelCase_   :       str  ,		UpperCamelCase_   :       str )   ->    Union[str, Any]:







			'''simple docstring'''



			lowerCAmelCase__									=							datasets.Dataset.from_file(
			    filename=os.path.join(UpperCamelCase_  ,		"beta.arrow" )  ,		info=datasets.DatasetInfo(features=UpperCamelCase_ ) )
			dataset.set_format("numpy" )
			for col in feats:
						lowerCAmelCase__									=							dataset[col]







def 					A       ( )   ->    str:







			'''simple docstring'''



			lowerCAmelCase__									=							{}
			lowerCAmelCase__									=							(
			    read_unformated,
			    read_formatted_as_numpy,
			    read_batch_unformated,
			    read_batch_formatted_as_numpy,
			    read_col_unformated,
			    read_col_formatted_as_numpy,
			)
			with tempfile.TemporaryDirectory() as tmp_dir:
						lowerCAmelCase__									=							datasets.Features({"image": ArrayaD(UpperCamelCase_  ,		dtype="float32" )} )
						lowerCAmelCase__									=							generate_examples(features=UpperCamelCase_  ,		num_examples=UpperCamelCase_ )
						lowerCAmelCase__									=							write(UpperCamelCase_  ,		UpperCamelCase_  ,		UpperCamelCase_ )
						for read_func in read_functions:
									lowerCAmelCase__									=							read_func(UpperCamelCase_  ,		UpperCamelCase_ )

			with tempfile.TemporaryDirectory() as tmp_dir:
						# don't use fixed length for fair comparison
						# feats = datasets.Features(
						#     {"image": datasets.Sequence(datasets.Sequence(datasets.Value("float32"), SPEED_TEST_SHAPE[1]), SPEED_TEST_SHAPE[0])}
						# )
						lowerCAmelCase__									=							datasets.Features({"image": datasets.Sequence(datasets.Sequence(datasets.Value("float32" ) ) )} )
						lowerCAmelCase__									=							generate_examples(
						    features=UpperCamelCase_  ,		num_examples=UpperCamelCase_  ,		seq_shapes={"image": SPEED_TEST_SHAPE} )
						lowerCAmelCase__									=							write(UpperCamelCase_  ,		UpperCamelCase_  ,		UpperCamelCase_ )
						for read_func in read_functions:
									lowerCAmelCase__									=							read_func(UpperCamelCase_  ,		UpperCamelCase_ )

			with tempfile.TemporaryDirectory() as tmp_dir:
						# don't use fixed length for fair comparison
						# feats = datasets.Features(
						#     {"image": datasets.Sequence(datasets.Value("float32"), SPEED_TEST_SHAPE[0] * SPEED_TEST_SHAPE[1])}
						# )
						lowerCAmelCase__									=							datasets.Features({"image": datasets.Sequence(datasets.Value("float32" ) )} )
						lowerCAmelCase__									=							generate_examples(
						    features=UpperCamelCase_  ,		num_examples=UpperCamelCase_  ,		seq_shapes={"image": [SPEED_TEST_SHAPE[0] * SPEED_TEST_SHAPE[1]]}  ,		)
						lowerCAmelCase__									=							write(UpperCamelCase_  ,		UpperCamelCase_  ,		UpperCamelCase_ )
						for read_func in read_functions:
									lowerCAmelCase__									=							read_func(UpperCamelCase_  ,		UpperCamelCase_ )

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


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







'''simple docstring'''

def 					A       ( )   ->    str:







			'''simple docstring'''



			lowerCAmelCase__									=							1

			while True:
						if (
						    sorted(str(UpperCamelCase_ ) )
						    == sorted(str(2 * i ) )
						    == sorted(str(3 * i ) )
						    == sorted(str(4 * i ) )
						    == sorted(str(5 * i ) )
						    == sorted(str(6 * i ) )
						):
									return i

						i += 1


if __name__ == "__main__":
		print(solution())





