



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_      			=  (30, 487)
UpperCamelCase_      			=  (36, 1_024)
UpperCamelCase_      			=  (100, 100)
UpperCamelCase_      			=  100

UpperCamelCase_      			=  datasets.Features(
    {"text": ArrayaD(SHAPE_TEST_1, dtype="float32"), "image": ArrayaD(SHAPE_TEST_2, dtype="float32")}
)

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







@get_duration
def 							A     (						__UpperCAmelCase				,   __UpperCAmelCase				,   __UpperCAmelCase      )			->			Optional[Any]:



						'''simple docstring'''






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







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



						'''simple docstring'''






						UpperCAmelCase_					=	datasets.Dataset.from_file(
						    filename=os.path.join(lowerCAmelCase_				,   '''beta.arrow'''      )				,   info=datasets.DatasetInfo(features=lowerCAmelCase_      )      )
						for _ in dataset:
												pass







@get_duration
def 							A     (						__UpperCAmelCase				,   __UpperCAmelCase      )			->			str:



						'''simple docstring'''






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







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



						'''simple docstring'''






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







@get_duration
def 							A     (						__UpperCAmelCase				,   __UpperCAmelCase      )			->			Dict:



						'''simple docstring'''






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







@get_duration
def 							A     (						__UpperCAmelCase				,   __UpperCAmelCase      )			->			int:



						'''simple docstring'''






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







@get_duration
def 							A     (						__UpperCAmelCase				,   __UpperCAmelCase      )			->			List[str]:



						'''simple docstring'''






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







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



						'''simple docstring'''






						UpperCAmelCase_					=	{}
						UpperCAmelCase_					=	(
						    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:
												UpperCAmelCase_					=	datasets.Features({'''image''': ArrayaD(lowerCAmelCase_				,   dtype='''float32'''      )}      )
												UpperCAmelCase_					=	generate_examples(features=lowerCAmelCase_				,   num_examples=lowerCAmelCase_      )
												UpperCAmelCase_					=	write(lowerCAmelCase_				,   lowerCAmelCase_				,   lowerCAmelCase_      )
												for read_func in read_functions:
																		UpperCAmelCase_					=	read_func(lowerCAmelCase_				,   lowerCAmelCase_      )

						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])}
												# )
												UpperCAmelCase_					=	datasets.Features({'''image''': datasets.Sequence(datasets.Sequence(datasets.Value('''float32'''      )      )      )}      )
												UpperCAmelCase_					=	generate_examples(
												    features=lowerCAmelCase_				,   num_examples=lowerCAmelCase_				,   seq_shapes={'''image''': SPEED_TEST_SHAPE}      )
												UpperCAmelCase_					=	write(lowerCAmelCase_				,   lowerCAmelCase_				,   lowerCAmelCase_      )
												for read_func in read_functions:
																		UpperCAmelCase_					=	read_func(lowerCAmelCase_				,   lowerCAmelCase_      )

						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])}
												# )
												UpperCAmelCase_					=	datasets.Features({'''image''': datasets.Sequence(datasets.Value('''float32'''      )      )}      )
												UpperCAmelCase_					=	generate_examples(
												    features=lowerCAmelCase_				,   num_examples=lowerCAmelCase_				,   seq_shapes={'''image''': [SPEED_TEST_SHAPE[0] * SPEED_TEST_SHAPE[1]]}				,   )
												UpperCAmelCase_					=	write(lowerCAmelCase_				,   lowerCAmelCase_				,   lowerCAmelCase_      )
												for read_func in read_functions:
																		UpperCAmelCase_					=	read_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_array_xd()






from __future__ import annotations

def 				UpperCamelCase					(     lowerCAmelCase_ )		->    set[int]:




       '''simple docstring'''






       _A=						{1}
       _A=						[1]
       for _ in range(2							,       depth + 1 ):
              _A=						[*previous_coefficients, 0]
              _A=						[0, *previous_coefficients]
              _A=						[]
              for x, y in zip(lowerCAmelCase_							,       lowerCAmelCase_ ):
                     coefficients.add(x + y )
                     previous_coefficients.append(x + y )
       return coefficients

def 				UpperCamelCase					(     lowerCAmelCase_ )		->    set[int]:




       '''simple docstring'''






       _A=						set()
       for number in unique_coefficients:
              _A=						2
              _A=						number
              while divisor**2 <= copy_number:
                     _A=						0
                     while copy_number % divisor == 0:
                            copy_number //= divisor
                            multiplicity += 1
                     if multiplicity >= 2:
                            non_squarefrees.add(lowerCAmelCase_ )
                            break
                     divisor += 1

       return unique_coefficients.difference(lowerCAmelCase_ )

def 				UpperCamelCase					(     lowerCAmelCase_ = 51 )		->    int:




       '''simple docstring'''






       _A=						get_pascal_triangle_unique_coefficients(lowerCAmelCase_ )
       _A=						get_squarefrees(lowerCAmelCase_ )
       return sum(lowerCAmelCase_ )


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