




'''simple docstring'''







from __future__ import annotations

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

A     =TypeVar('T')
A     =TypeVar('U')


class 			_a  (	Generic[T, U] ):
       def __init__(	self						:	str   ,				lowercase						:	T | None   ,				lowercase						:	U | None				):



           '''simple docstring'''

           UpperCAmelCase			       =		key
           UpperCAmelCase			       =		val
           UpperCAmelCase			       =		None
           UpperCAmelCase			       =		None







       def __repr__(	self						:	Optional[int]				):



           '''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						:	Union[str, Any]				):



           '''simple docstring'''

           UpperCAmelCase			       =		DoubleLinkedListNode(lowercase   ,				lowercase				)
           UpperCAmelCase			       =		DoubleLinkedListNode(lowercase   ,				lowercase				)
           UpperCAmelCase       ,     UpperCAmelCase			       =		self.rear, self.head
       def __repr__(	self						:	Any				):



           '''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						:	Any   ,				lowercase						:	DoubleLinkedListNode[T, U]				):



           '''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						:	Any   ,				lowercase						:	DoubleLinkedListNode[T, U]				):



           '''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] ):
       __a				:     dict[Callable[[T], U], LRUCache[T, U]]   				=					{}
       def __init__(	self						:	int   ,				lowercase						:	int				):



           '''simple docstring'''

           UpperCAmelCase			       =		DoubleLinkedList()
           UpperCAmelCase			       =		capacity
           UpperCAmelCase			       =		0
           UpperCAmelCase			       =		0
           UpperCAmelCase			       =		0
           UpperCAmelCase			       =		{}
       def __repr__(	self						:	Optional[int]				):



           '''simple docstring'''

           return (
               f"CacheInfo(hits={self.hits}, misses={self.miss}, "
               f"capacity={self.capacity}, current size={self.num_keys})"
           )
       def __contains__(	self						:	str   ,				lowercase						:	T				):



           '''simple docstring'''

           return key in self.cache
       def     A      (	self						:	Union[str, Any]   ,				lowercase						:	T				):



           '''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						:	str   ,				lowercase						:	T   ,				lowercase						:	U				):



           '''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						:	Any   ,				lowercase						:	int = 128				):



           '''simple docstring'''

           def cache_decorator_inner(lowercase						:	Callable[[T], U]				) -> Callable[..., U]:
               def cache_decorator_wrapper(*lowercase						:	T				) -> 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()










from .glue import glue_convert_examples_to_features, glue_output_modes, glue_processors, glue_tasks_num_labels
from .squad import SquadExample, SquadFeatures, SquadVaProcessor, SquadVaProcessor, squad_convert_examples_to_features
from .utils import DataProcessor, InputExample, InputFeatures, SingleSentenceClassificationProcessor
from .xnli import xnli_output_modes, xnli_processors, xnli_tasks_num_labels




