
import json
import os
import tempfile

import datasets
from utils import generate_example_dataset, get_duration


_A       =					50_00_00

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






@get_duration
def        lowerCamelCase__    (    __lowerCAmelCase  :  datasets.Dataset    ):




			"""simple docstring"""


			lowerCAmelCase_      =     dataset.select(range(0   ,							len(__lowerCAmelCase    )   ,							2    )    )






@get_duration
def        lowerCamelCase__    (    __lowerCAmelCase  :  datasets.Dataset    ):




			"""simple docstring"""


			lowerCAmelCase_      =     dataset.sort("numbers"    )






@get_duration
def        lowerCamelCase__    (    __lowerCAmelCase  :  datasets.Dataset    ):




			"""simple docstring"""


			lowerCAmelCase_      =     dataset.shuffle()






@get_duration
def        lowerCamelCase__    (    __lowerCAmelCase  :  datasets.Dataset    ):




			"""simple docstring"""


			lowerCAmelCase_      =     dataset.train_test_split(0.1    )






@get_duration
def        lowerCamelCase__    (    __lowerCAmelCase  :  datasets.Dataset   ,							__lowerCAmelCase  :  Union[str, Any]=10    ):




			"""simple docstring"""


			for shard_id in range(__lowerCAmelCase    ):
						lowerCAmelCase_      =     dataset.shard(__lowerCAmelCase   ,							__lowerCAmelCase    )






def        lowerCamelCase__    (    ):




			"""simple docstring"""


			lowerCAmelCase_      =     {"num examples": SPEED_TEST_N_EXAMPLES}
			lowerCAmelCase_      =     (select, sort, shuffle, train_test_split, shard)
			with tempfile.TemporaryDirectory() as tmp_dir:
						print("generating dataset"    )
						lowerCAmelCase_      =     datasets.Features({"text": datasets.Value("string"    ), "numbers": datasets.Value("float32"    )}    )
						lowerCAmelCase_      =     generate_example_dataset(
						    os.path.join(__lowerCAmelCase   ,							"dataset.arrow"    )   ,							__lowerCAmelCase   ,							num_examples=__lowerCAmelCase    )
						print("Functions"    )
						for func in functions:
									print(func.__name__    )
									lowerCAmelCase_      =     func(__lowerCAmelCase    )

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


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





from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


_A       =					{"configuration_nat": ["NAT_PRETRAINED_CONFIG_ARCHIVE_MAP", "NatConfig"]}


try:
			if not is_torch_available():
						raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
			pass
else:
			_A       =					[
			    "NAT_PRETRAINED_MODEL_ARCHIVE_LIST",
			    "NatForImageClassification",
			    "NatModel",
			    "NatPreTrainedModel",
			    "NatBackbone",
			]

if TYPE_CHECKING:
			from .configuration_nat import NAT_PRETRAINED_CONFIG_ARCHIVE_MAP, NatConfig

			try:
						if not is_torch_available():
									raise OptionalDependencyNotAvailable()
			except OptionalDependencyNotAvailable:
						pass
			else:
						from .modeling_nat import (
						    NAT_PRETRAINED_MODEL_ARCHIVE_LIST,
						    NatBackbone,
						    NatForImageClassification,
						    NatModel,
						    NatPreTrainedModel,
						)

else:
			import sys

			_A       =					_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)



