





'''simple docstring'''






# Lint as: python3
# pylint: enable=line-too-long
# pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position

lowerCAmelCase       		=      """2.13.1"""

import platform

import pyarrow
from packaging import version


if version.parse(platform.python_version()) < version.parse("""3.7"""):
					raise ImportWarning(
					    """To use `datasets`, Python>=3.7 is required, and the current version of Python doesn't match this condition."""
					)

if version.parse(pyarrow.__version__).major < 8:
					raise ImportWarning(
					    """To use `datasets`, the module `pyarrow>=8.0.0` is required, and the current version of `pyarrow` doesn't match this condition.\n"""
					    """If you are running this in a Google Colab, you should probably just restart the runtime to use the right version of `pyarrow`."""
					)

del platform
del pyarrow
del version

from .arrow_dataset import Dataset
from .arrow_reader import ReadInstruction
from .builder import ArrowBasedBuilder, BeamBasedBuilder, BuilderConfig, DatasetBuilder, GeneratorBasedBuilder
from .combine import concatenate_datasets, interleave_datasets
from .dataset_dict import DatasetDict, IterableDatasetDict
from .download import *
from .features import *
from .fingerprint import disable_caching, enable_caching, is_caching_enabled, set_caching_enabled
from .info import DatasetInfo, MetricInfo
from .inspect import (
    get_dataset_config_info,
    get_dataset_config_names,
    get_dataset_infos,
    get_dataset_split_names,
    inspect_dataset,
    inspect_metric,
    list_datasets,
    list_metrics,
)
from .iterable_dataset import IterableDataset
from .load import load_dataset, load_dataset_builder, load_from_disk, load_metric
from .metric import Metric
from .splits import (
    NamedSplit,
    NamedSplitAll,
    Split,
    SplitBase,
    SplitDict,
    SplitGenerator,
    SplitInfo,
    SubSplitInfo,
    percent,
)
from .tasks import *
from .utils import *
from .utils import logging


# deprecated modules
from datasets import arrow_dataset as _arrow_dataset  # isort:skip
from datasets import utils as _utils  # isort:skip
from datasets.utils import download_manager as _deprecated_download_manager  # isort:skip

lowerCAmelCase       		=      concatenate_datasets
lowerCAmelCase       		=      DownloadConfig
lowerCAmelCase       		=      DownloadManager
lowerCAmelCase       		=      DownloadMode
lowerCAmelCase       		=      DownloadConfig
lowerCAmelCase       		=      DownloadMode
lowerCAmelCase       		=      DownloadManager

del _arrow_dataset, _utils, _deprecated_download_manager










'''simple docstring'''






import os
import tempfile
import unittest
from pathlib import Path

from transformers import AutoConfig, is_tf_available
from transformers.testing_utils import require_tf


if is_tf_available():
					import tensorflow as tf

					from transformers import TensorFlowBenchmark, TensorFlowBenchmarkArguments
@require_tf
class 		lowerCamelCase  (      unittest.TestCase       ):



	def   _lowerCamelCase    (   self		,      a_	):
			for model_result in results.values():
					for batch_size, sequence_length in zip(model_result["bs"]		,      model_result["ss"]	):
							lowerCAmelCase     :    Tuple						=   model_result["result"][batch_size][sequence_length]
							self.assertIsNotNone(a_	)



	def   _lowerCamelCase    (   self	):
			lowerCAmelCase     :    Optional[int]						=   "sshleifer/tiny-gpt2"
			lowerCAmelCase     :    Tuple						=   TensorFlowBenchmarkArguments(
			    models=[MODEL_ID]		,      training=a_		,      inference=a_		,      sequence_lengths=[8]		,      batch_sizes=[1]		,      eager_mode=a_		,      multi_process=a_		,      )
			lowerCAmelCase     :    Optional[Any]						=   TensorFlowBenchmark(a_	)
			lowerCAmelCase     :    Optional[Any]						=   benchmark.run()
			self.check_results_dict_not_empty(results.time_inference_result	)
			self.check_results_dict_not_empty(results.memory_inference_result	)



	def   _lowerCamelCase    (   self	):
			lowerCAmelCase     :    Union[str, Any]						=   "sgugger/tiny-distilbert-classification"
			lowerCAmelCase     :    Tuple						=   TensorFlowBenchmarkArguments(
			    models=[MODEL_ID]		,      training=a_		,      inference=a_		,      sequence_lengths=[8]		,      batch_sizes=[1]		,      multi_process=a_		,      only_pretrain_model=a_		,      )
			lowerCAmelCase     :    Any						=   TensorFlowBenchmark(a_	)
			lowerCAmelCase     :    str						=   benchmark.run()
			self.check_results_dict_not_empty(results.time_inference_result	)
			self.check_results_dict_not_empty(results.memory_inference_result	)



	def   _lowerCamelCase    (   self	):
			lowerCAmelCase     :    Union[str, Any]						=   "sshleifer/tiny-gpt2"
			lowerCAmelCase     :    str						=   TensorFlowBenchmarkArguments(
			    models=[MODEL_ID]		,      training=a_		,      inference=a_		,      sequence_lengths=[8]		,      batch_sizes=[1]		,      multi_process=a_		,      )
			lowerCAmelCase     :    List[str]						=   TensorFlowBenchmark(a_	)
			lowerCAmelCase     :    str						=   benchmark.run()
			self.check_results_dict_not_empty(results.time_inference_result	)
			self.check_results_dict_not_empty(results.memory_inference_result	)



	def   _lowerCamelCase    (   self	):
			lowerCAmelCase     :    List[str]						=   "sshleifer/tiny-gpt2"
			lowerCAmelCase     :    Union[str, Any]						=   AutoConfig.from_pretrained(a_	)
			lowerCAmelCase     :    Optional[Any]						=   TensorFlowBenchmarkArguments(
			    models=[MODEL_ID]		,      training=a_		,      inference=a_		,      sequence_lengths=[8]		,      batch_sizes=[1]		,      eager_mode=a_		,      multi_process=a_		,      )
			lowerCAmelCase     :    Any						=   TensorFlowBenchmark(a_		,      [config]	)
			lowerCAmelCase     :    Union[str, Any]						=   benchmark.run()
			self.check_results_dict_not_empty(results.time_inference_result	)
			self.check_results_dict_not_empty(results.memory_inference_result	)



	def   _lowerCamelCase    (   self	):
			lowerCAmelCase     :    int						=   "sshleifer/tiny-gpt2"
			lowerCAmelCase     :    Union[str, Any]						=   AutoConfig.from_pretrained(a_	)
			lowerCAmelCase     :    Union[str, Any]						=   TensorFlowBenchmarkArguments(
			    models=[MODEL_ID]		,      training=a_		,      inference=a_		,      sequence_lengths=[8]		,      batch_sizes=[1]		,      multi_process=a_		,      )
			lowerCAmelCase     :    Tuple						=   TensorFlowBenchmark(a_		,      [config]	)
			lowerCAmelCase     :    Any						=   benchmark.run()
			self.check_results_dict_not_empty(results.time_inference_result	)
			self.check_results_dict_not_empty(results.memory_inference_result	)



	def   _lowerCamelCase    (   self	):
			lowerCAmelCase     :    Tuple						=   "sshleifer/tiny-gpt2"
			lowerCAmelCase     :    List[str]						=   TensorFlowBenchmarkArguments(
			    models=[MODEL_ID]		,      training=a_		,      inference=a_		,      sequence_lengths=[8]		,      batch_sizes=[1]		,      multi_process=a_		,      )
			lowerCAmelCase     :    List[str]						=   TensorFlowBenchmark(a_	)
			lowerCAmelCase     :    str						=   benchmark.run()
			self.check_results_dict_not_empty(results.time_train_result	)
			self.check_results_dict_not_empty(results.memory_train_result	)



	def   _lowerCamelCase    (   self	):
			lowerCAmelCase     :    List[Any]						=   "sshleifer/tiny-gpt2"
			lowerCAmelCase     :    Union[str, Any]						=   AutoConfig.from_pretrained(a_	)
			lowerCAmelCase     :    Dict						=   TensorFlowBenchmarkArguments(
			    models=[MODEL_ID]		,      training=a_		,      inference=a_		,      sequence_lengths=[8]		,      batch_sizes=[1]		,      multi_process=a_		,      )
			lowerCAmelCase     :    Dict						=   TensorFlowBenchmark(a_		,      [config]	)
			lowerCAmelCase     :    int						=   benchmark.run()
			self.check_results_dict_not_empty(results.time_train_result	)
			self.check_results_dict_not_empty(results.memory_train_result	)



	def   _lowerCamelCase    (   self	):
			lowerCAmelCase     :    str						=   "patrickvonplaten/t5-tiny-random"
			lowerCAmelCase     :    Tuple						=   AutoConfig.from_pretrained(a_	)
			lowerCAmelCase     :    Dict						=   TensorFlowBenchmarkArguments(
			    models=[MODEL_ID]		,      training=a_		,      inference=a_		,      sequence_lengths=[8]		,      batch_sizes=[1]		,      multi_process=a_		,      )
			lowerCAmelCase     :    List[str]						=   TensorFlowBenchmark(a_		,      configs=[config]	)
			lowerCAmelCase     :    List[Any]						=   benchmark.run()
			self.check_results_dict_not_empty(results.time_inference_result	)
			self.check_results_dict_not_empty(results.memory_inference_result	)



	@unittest.skipIf(is_tf_available() and len(tf.config.list_physical_devices("GPU"	)	) == 0		,      "Cannot do xla on CPU."	)
	def   _lowerCamelCase    (   self	):
			lowerCAmelCase     :    str						=   "sshleifer/tiny-gpt2"
			lowerCAmelCase     :    List[Any]						=   TensorFlowBenchmarkArguments(
			    models=[MODEL_ID]		,      training=a_		,      inference=a_		,      sequence_lengths=[8]		,      batch_sizes=[1]		,      use_xla=a_		,      multi_process=a_		,      )
			lowerCAmelCase     :    Any						=   TensorFlowBenchmark(a_	)
			lowerCAmelCase     :    str						=   benchmark.run()
			self.check_results_dict_not_empty(results.time_inference_result	)
			self.check_results_dict_not_empty(results.memory_inference_result	)



	def   _lowerCamelCase    (   self	):
			lowerCAmelCase     :    Tuple						=   "sshleifer/tiny-gpt2"
			with tempfile.TemporaryDirectory() as tmp_dir:
					lowerCAmelCase     :    Optional[int]						=   TensorFlowBenchmarkArguments(
					    models=[MODEL_ID]		,      inference=a_		,      save_to_csv=a_		,      sequence_lengths=[8]		,      batch_sizes=[1]		,      inference_time_csv_file=os.path.join(a_		,      "inf_time.csv"	)		,      inference_memory_csv_file=os.path.join(a_		,      "inf_mem.csv"	)		,      env_info_csv_file=os.path.join(a_		,      "env.csv"	)		,      multi_process=a_		,      )
					lowerCAmelCase     :    Optional[Any]						=   TensorFlowBenchmark(a_	)
					benchmark.run()
					self.assertTrue(Path(os.path.join(a_		,      "inf_time.csv"	)	).exists()	)
					self.assertTrue(Path(os.path.join(a_		,      "inf_mem.csv"	)	).exists()	)
					self.assertTrue(Path(os.path.join(a_		,      "env.csv"	)	).exists()	)





	def   _lowerCamelCase    (   self	):
			lowerCAmelCase     :    Any						=   "sshleifer/tiny-gpt2"

			def _check_summary_is_not_empty(a_	):
					self.assertTrue(hasattr(a_		,      "sequential"	)	)
					self.assertTrue(hasattr(a_		,      "cumulative"	)	)
					self.assertTrue(hasattr(a_		,      "current"	)	)
					self.assertTrue(hasattr(a_		,      "total"	)	)

			with tempfile.TemporaryDirectory() as tmp_dir:
					lowerCAmelCase     :    int						=   TensorFlowBenchmarkArguments(
					    models=[MODEL_ID]		,      inference=a_		,      sequence_lengths=[8]		,      batch_sizes=[1]		,      log_filename=os.path.join(a_		,      "log.txt"	)		,      log_print=a_		,      trace_memory_line_by_line=a_		,      eager_mode=a_		,      multi_process=a_		,      )
					lowerCAmelCase     :    Optional[Any]						=   TensorFlowBenchmark(a_	)
					lowerCAmelCase     :    Tuple						=   benchmark.run()
					_check_summary_is_not_empty(result.inference_summary	)
					self.assertTrue(Path(os.path.join(a_		,      "log.txt"	)	).exists()	)



