'''simple docstring'''





import os
import sys
import unittest


UpperCAmelCase_			    =							os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
sys.path.append(os.path.join(git_repo_path, '''utils'''))

import check_dummies  # noqa: E402
from check_dummies import create_dummy_files, create_dummy_object, find_backend, read_init  # noqa: E402


# Align TRANSFORMERS_PATH in check_dummies with the current path
UpperCAmelCase_			    =							os.path.join(git_repo_path, '''src''', '''transformers''')

UpperCAmelCase_			    =							'''
{0} = None
'''

UpperCAmelCase_			    =							'''
class {0}(metaclass=DummyObject):
    _backends = {1}

    def __init__(self, *args, **kwargs):
        requires_backends(self, {1})
'''


UpperCAmelCase_			    =							'''
def {0}(*args, **kwargs):
    requires_backends({0}, {1})
'''




class  __magic_name__  (		unittest.TestCase    ):





   """simple docstring"""




   def   lowerCAmelCase						(	self					:  List[str]							):



    """simple docstring"""



    _UpperCamelCase:     List[Any]							= find_backend('''    _import_structure["models.albert"].append("AlbertTokenizerFast")'''							)
    self.assertIsNone(_lowercase							)

    _UpperCamelCase:     List[Any]							= find_backend('''    if not is_tokenizers_available():'''							)
    self.assertEqual(_lowercase		,  '''tokenizers'''							)

    _UpperCamelCase:     Union[str, Any]							= find_backend('''    if not is_tensorflow_text_available():'''							)
    self.assertEqual(_lowercase		,  '''tensorflow_text'''							)

    _UpperCamelCase:     List[str]							= find_backend('''    if not (is_sentencepiece_available() and is_tokenizers_available()):'''							)
    self.assertEqual(_lowercase		,  '''sentencepiece_and_tokenizers'''							)

    _UpperCamelCase:     List[Any]							= find_backend(
        '''    if not (is_sentencepiece_available() and is_tensorflow_text_available()):'''							)
    self.assertEqual(_lowercase		,  '''sentencepiece_and_tensorflow_text'''							)

    _UpperCamelCase:     Any							= find_backend(
        '''    if not (is_sentencepiece_available() and is_tokenizers_available() and is_vision_available()):'''							)
    self.assertEqual(_lowercase		,  '''sentencepiece_and_tokenizers_and_vision'''							)



   def   lowerCAmelCase						(	self					:  int							):



    """simple docstring"""



    _UpperCamelCase:     Optional[Any]							= read_init()
    # We don't assert on the exact list of keys to allow for smooth grow of backend-specific objects
    self.assertIn('''torch'''		,  _lowercase							)
    self.assertIn('''tensorflow_text'''		,  _lowercase							)
    self.assertIn('''sentencepiece_and_tokenizers'''		,  _lowercase							)

    # Likewise, we can't assert on the exact content of a key
    self.assertIn('''BertModel'''		,  objects['''torch''']							)
    self.assertIn('''TFBertModel'''		,  objects['''tf''']							)
    self.assertIn('''FlaxBertModel'''		,  objects['''flax''']							)
    self.assertIn('''BertModel'''		,  objects['''torch''']							)
    self.assertIn('''TFBertTokenizer'''		,  objects['''tensorflow_text''']							)
    self.assertIn('''convert_slow_tokenizer'''		,  objects['''sentencepiece_and_tokenizers''']							)



   def   lowerCAmelCase						(	self					:  int							):



    """simple docstring"""



    _UpperCamelCase:     Union[str, Any]							= create_dummy_object('''CONSTANT'''		,  '''\'torch\''''							)
    self.assertEqual(_lowercase		,  '''\nCONSTANT = None\n'''							)

    _UpperCamelCase:     Optional[Any]							= create_dummy_object('''function'''		,  '''\'torch\''''							)
    self.assertEqual(
        _lowercase		,  '''\ndef function(*args, **kwargs):\n    requires_backends(function, \'torch\')\n'''							)

    _UpperCamelCase:     List[str]							= '''
class FakeClass(metaclass=DummyObject):
    _backends = \'torch\'

    def __init__(self, *args, **kwargs):
        requires_backends(self, \'torch\')
'''
    _UpperCamelCase:     List[Any]							= create_dummy_object('''FakeClass'''		,  '''\'torch\''''							)
    self.assertEqual(_lowercase		,  _lowercase							)



   def   lowerCAmelCase						(	self					:  Optional[Any]							):



    """simple docstring"""



    _UpperCamelCase:     int							= '''# This file is autogenerated by the command `make fix-copies`, do not edit.
from ..utils import DummyObject, requires_backends


CONSTANT = None


def function(*args, **kwargs):
    requires_backends(function, ["torch"])


class FakeClass(metaclass=DummyObject):
    _backends = ["torch"]

    def __init__(self, *args, **kwargs):
        requires_backends(self, ["torch"])
'''
    _UpperCamelCase:     Tuple							= create_dummy_files({'''torch''': ['''CONSTANT''', '''function''', '''FakeClass''']}							)
    self.assertEqual(dummy_files['''torch''']		,  _lowercase							)
# Lint as: python3
# pylint: enable=line-too-long
# pylint: disable=g-import-not-at-top,g-bad-import-order,wrong-import-position

UpperCAmelCase_			    =							'''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

UpperCAmelCase_			    =							concatenate_datasets
UpperCAmelCase_			    =							DownloadConfig
UpperCAmelCase_			    =							DownloadManager
UpperCAmelCase_			    =							DownloadMode
UpperCAmelCase_			    =							DownloadConfig
UpperCAmelCase_			    =							DownloadMode
UpperCAmelCase_			    =							DownloadManager

del _arrow_dataset, _utils, _deprecated_download_manager