from __future__ import annotations

from collections.abc import Callable
from typing import Generic, TypeVar

__magic_name__								=TypeVar('''T''')
__magic_name__								=TypeVar('''U''')



class     _A   (    Generic[T, U]							):






  def __init__(self   ,				SCREAMING_SNAKE_CASE_   ,				SCREAMING_SNAKE_CASE_	)		->      Dict:





       '''simple docstring'''





       UpperCamelCase__										=      key
       UpperCamelCase__										=      val
       UpperCamelCase__										=      None
       UpperCamelCase__										=      None






  def __repr__(self	)		->      List[str]:





       '''simple docstring'''





       return (
           F"Node: key: {self.key}, val: {self.val}, "
           F"has next: {bool(self.next	)}, has prev: {bool(self.prev	)}"
       )



class     _A   (    Generic[T, U]							):






  def __init__(self	)		->      Optional[int]:





       '''simple docstring'''





       UpperCamelCase__										=      DoubleLinkedListNode(lowercase_   ,				lowercase_	)
       UpperCamelCase__										=      DoubleLinkedListNode(lowercase_   ,				lowercase_	)
       UpperCamelCase__										=      self.rear, self.head






  def __repr__(self	)		->      Dict:





       '''simple docstring'''





       UpperCamelCase__										=      ["DoubleLinkedList"]
       UpperCamelCase__										=      self.head
       while node.next is not None:
            rep.append(str(lowercase_	)	)
            UpperCamelCase__										=      node.next
       rep.append(str(self.rear	)	)
       return ",\n    ".join(lowercase_	)






  def 		_a					(self   ,				SCREAMING_SNAKE_CASE_	)		->      List[str]:





       '''simple docstring'''





       UpperCamelCase__										=      self.rear.prev

       # All nodes other than self.head are guaranteed to have non-None previous
       assert previous is not None

       UpperCamelCase__										=      node
       UpperCamelCase__										=      previous
       UpperCamelCase__										=      node
       UpperCamelCase__										=      self.rear






  def 		_a					(self   ,				SCREAMING_SNAKE_CASE_	)		->      Optional[int]:





       '''simple docstring'''





       if node.prev is None or node.next is None:
            return None

       UpperCamelCase__										=      node.next
       UpperCamelCase__										=      node.prev
       UpperCamelCase__										=      None
       UpperCamelCase__										=      None
       return node



class     _A   (    Generic[T, U]							):
  SCREAMING_SNAKE_CASE_	:	Union[str, Any]						={}






  def __init__(self   ,				SCREAMING_SNAKE_CASE_	)		->      Tuple:





       '''simple docstring'''





       UpperCamelCase__										=      DoubleLinkedList()
       UpperCamelCase__										=      capacity
       UpperCamelCase__										=      0
       UpperCamelCase__										=      0
       UpperCamelCase__										=      0
       UpperCamelCase__										=      {}






  def __repr__(self	)		->      Dict:





       '''simple docstring'''





       return (
           F"CacheInfo(hits={self.hits}, misses={self.miss}, "
           F"capacity={self.capacity}, current size={self.num_keys})"
       )






  def __contains__(self   ,				SCREAMING_SNAKE_CASE_	)		->      List[Any]:





       '''simple docstring'''





       return key in self.cache






  def 		_a					(self   ,				SCREAMING_SNAKE_CASE_	)		->      int:





       '''simple docstring'''





       if key in self.cache:
            self.hits += 1
            UpperCamelCase__										=      self.cache[key]
            UpperCamelCase__										=      self.list.remove(self.cache[key]	)
            assert node == value_node

            # node is guaranteed not None because it is in self.cache
            assert node is not None
            self.list.add(lowercase_	)
            return node.val
       self.miss += 1
       return None






  def 		_a					(self   ,				SCREAMING_SNAKE_CASE_   ,				SCREAMING_SNAKE_CASE_	)		->      Union[str, Any]:





       '''simple docstring'''





       if key not in self.cache:
            if self.num_keys >= self.capacity:
                 # delete first node (oldest) when over capacity
                 UpperCamelCase__										=      self.list.head.next

                 # guaranteed to have a non-None first node when num_keys > 0
                 # explain to type checker via assertions
                 assert first_node is not None
                 assert first_node.key is not None
                 assert (
                     self.list.remove(lowercase_	) is not None
                 )  # node guaranteed to be in list assert node.key is not None

                 del self.cache[first_node.key]
                 self.num_keys -= 1
            UpperCamelCase__										=      DoubleLinkedListNode(lowercase_   ,				lowercase_	)
            self.list.add(self.cache[key]	)
            self.num_keys += 1

       else:
            # bump node to the end of the list, update value
            UpperCamelCase__										=      self.list.remove(self.cache[key]	)
            assert node is not None  # node guaranteed to be in list
            UpperCamelCase__										=      value
            self.list.add(lowercase_	)






  @classmethod
  def 		_a					(cls   ,				SCREAMING_SNAKE_CASE_ = 128	)		->      str:





       '''simple docstring'''





       def cache_decorator_inner(SCREAMING_SNAKE_CASE_	) -> Callable[..., U]:
            def cache_decorator_wrapper(*SCREAMING_SNAKE_CASE_	) -> U:
                 if func not in cls.decorator_function_to_instance_map:
                      UpperCamelCase__										=      LRUCache(lowercase_	)

                 UpperCamelCase__										=      cls.decorator_function_to_instance_map[func].get(args[0]	)
                 if result is None:
                      UpperCamelCase__										=      func(*lowercase_	)
                      cls.decorator_function_to_instance_map[func].put(args[0]   ,				lowercase_	)
                 return result

            def cache_info() -> LRUCache[T, U]:
                 return cls.decorator_function_to_instance_map[func]

            setattr(lowercase_   ,				'''cache_info'''   ,				lowercase_	)  # noqa: B010

            return cache_decorator_wrapper

       return cache_decorator_inner


if __name__ == "__main__":
     import doctest

     doctest.testmod()




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

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

__magic_name__								=concatenate_datasets
__magic_name__								=DownloadConfig
__magic_name__								=DownloadManager
__magic_name__								=DownloadMode
__magic_name__								=DownloadConfig
__magic_name__								=DownloadMode
__magic_name__								=DownloadManager

del _arrow_dataset, _utils, _deprecated_download_manager



