



'''simple docstring'''



import timeit

import numpy as np

import datasets
from datasets.arrow_writer import ArrowWriter
from datasets.features.features import _ArrayXD



def   __lowerCAmelCase					(							lowerCamelCase   :						int					):






	'''simple docstring'''




	def wrapper(*lowerCamelCase   :						Any				,		**lowerCamelCase   :						List[Any]					):
		__lowerCAmelCase												=  timeit.default_timer()
		__lowerCAmelCase												=  func(*lowerCamelCase				,		**lowerCamelCase					)
		__lowerCAmelCase												=  timeit.default_timer() - starttime
		return delta

	__lowerCAmelCase												=  func.__name__

	return wrapper



def   __lowerCAmelCase					(							lowerCamelCase   :						dict				,		lowerCamelCase   :						Tuple=1_00				,		lowerCamelCase   :						Any=None					):






	'''simple docstring'''




	__lowerCAmelCase												=  []
	__lowerCAmelCase												=  seq_shapes or {}
	for i in range(lowerCamelCase					):
		__lowerCAmelCase												=  {}
		for col_id, (k, v) in enumerate(features.items()					):
			if isinstance(lowerCamelCase				,		_ArrayXD					):
				__lowerCAmelCase												=  np.random.rand(*v.shape					).astype(v.dtype					)
			elif isinstance(lowerCamelCase				,		datasets.Value					):
				if v.dtype == "string":
					__lowerCAmelCase												=  "The small grey turtle was surprisingly fast when challenged."
				else:
					__lowerCAmelCase												=  np.random.randint(10				,		size=1					).astype(v.dtype					).item()
			elif isinstance(lowerCamelCase				,		datasets.Sequence					):
				while isinstance(lowerCamelCase				,		datasets.Sequence					):
					__lowerCAmelCase												=  v.feature
				__lowerCAmelCase												=  seq_shapes[k]
				__lowerCAmelCase												=  np.random.rand(*lowerCamelCase					).astype(v.dtype					)
			__lowerCAmelCase												=  data

		dummy_data.append((i, example)					)

	return dummy_data




def   __lowerCAmelCase					(							lowerCamelCase   :						List[Any]				,		lowerCamelCase   :						Tuple				,		lowerCamelCase   :						Dict=1_00				,		lowerCamelCase   :						int=None					):






	'''simple docstring'''




	__lowerCAmelCase												=  generate_examples(lowerCamelCase				,		num_examples=lowerCamelCase				,		seq_shapes=lowerCamelCase					)

	with ArrowWriter(features=lowerCamelCase				,		path=lowerCamelCase					) as writer:
		for key, record in dummy_data:
			__lowerCAmelCase												=  features.encode_example(lowerCamelCase					)
			writer.write(lowerCamelCase					)

		__lowerCAmelCase							,       __lowerCAmelCase												=  writer.finalize()

	if not num_final_examples == num_examples:
		raise ValueError(
		    f'''Error writing the dataset, wrote {num_final_examples} examples but should have written {num_examples}.'''					)

	__lowerCAmelCase												=  datasets.Dataset.from_file(filename=lowerCamelCase				,		info=datasets.DatasetInfo(features=lowerCamelCase					)					)

	return dataset




'''simple docstring'''



from __future__ import annotations



def   __lowerCAmelCase					(							lowerCamelCase   :						list					):






	'''simple docstring'''




	if not nums:
		raise ValueError("List is empty"					)
	return sum(lowerCamelCase					) / len(lowerCamelCase					)


if __name__ == "__main__":
	import doctest

	doctest.testmod()