



import timeit

import numpy as np

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



def 	__a					(   lowerCAmelCase_       : List[Any]    )				->			Tuple:






						'''simple docstring'''



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

						UpperCAmelCase_=       func.__name__

						return wrapper



def 	__a					(   lowerCAmelCase_       : Dict      ,lowerCAmelCase_       : Tuple=1_00      ,lowerCAmelCase_       : List[Any]=None    )				->			Optional[Any]:






						'''simple docstring'''



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

												dummy_data.append((i, example)    )

						return dummy_data



def 	__a					(   lowerCAmelCase_       : Tuple      ,lowerCAmelCase_       : str      ,lowerCAmelCase_       : Optional[Any]=1_00      ,lowerCAmelCase_       : Optional[int]=None    )				->			Union[str, Any]:






						'''simple docstring'''



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

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

												UpperCAmelCase_=       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}."""    )

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

						return dataset











import pytest

import datasets


# Import fixture modules as plugins
__A       =						['''tests.fixtures.files''', '''tests.fixtures.hub''', '''tests.fixtures.fsspec''']



def 	__a					(   lowerCAmelCase_       : Optional[Any]      ,lowerCAmelCase_       : Any    )				->			Tuple:






						'''simple docstring'''



						for item in items:
												if any(marker in item.keywords for marker in ["""integration""", """unit"""]    ):
																		continue
												item.add_marker(pytest.mark.unit    )



def 	__a					(   lowerCAmelCase_       : Tuple    )				->			Optional[Any]:






						'''simple docstring'''



						config.addinivalue_line("""markers"""      ,"""torchaudio_latest: mark test to run with torchaudio>=0.12"""    )



@pytest.fixture(autouse=lowerCAmelCase_    )
def 	__a					(   lowerCAmelCase_       : List[str]      ,lowerCAmelCase_       : List[str]    )				->			int:






						'''simple docstring'''



						UpperCAmelCase_=       tmp_path_factory.getbasetemp() / """cache"""
						UpperCAmelCase_=       test_hf_cache_home / """datasets"""
						UpperCAmelCase_=       test_hf_cache_home / """metrics"""
						UpperCAmelCase_=       test_hf_cache_home / """modules"""
						monkeypatch.setattr("""datasets.config.HF_DATASETS_CACHE"""      ,str(lowerCAmelCase_    )    )
						monkeypatch.setattr("""datasets.config.HF_METRICS_CACHE"""      ,str(lowerCAmelCase_    )    )
						monkeypatch.setattr("""datasets.config.HF_MODULES_CACHE"""      ,str(lowerCAmelCase_    )    )
						UpperCAmelCase_=       test_hf_datasets_cache / """downloads"""
						monkeypatch.setattr("""datasets.config.DOWNLOADED_DATASETS_PATH"""      ,str(lowerCAmelCase_    )    )
						UpperCAmelCase_=       test_hf_datasets_cache / """downloads""" / """extracted"""
						monkeypatch.setattr("""datasets.config.EXTRACTED_DATASETS_PATH"""      ,str(lowerCAmelCase_    )    )



@pytest.fixture(autouse=lowerCAmelCase_      ,scope="""session"""    )
def 	__a					(   )				->			Optional[int]:






						'''simple docstring'''



						datasets.disable_progress_bar()



@pytest.fixture(autouse=lowerCAmelCase_    )
def 	__a					(   lowerCAmelCase_       : int    )				->			str:






						'''simple docstring'''



						monkeypatch.setattr("""datasets.config.HF_UPDATE_DOWNLOAD_COUNTS"""      ,lowerCAmelCase_    )



@pytest.fixture
def 	__a					(   lowerCAmelCase_       : List[str]    )				->			Union[str, Any]:






						'''simple docstring'''



						monkeypatch.setattr("""sqlalchemy.util.deprecations.SILENCE_UBER_WARNING"""      ,lowerCAmelCase_    )




