code: 
  
  
  
  
  
  import posixpath
  from pathlib import Path
  from unittest.mock import patch
  
  import pytest
  from fsspec.implementations.local import AbstractFileSystem, LocalFileSystem, stringify_path
  from fsspec.registry import _registry as _fsspec_registry
  
  
  
  
  class 				_lowerCamelCase (    __lowerCamelCase    ):
  
  
  
        """simple docstring"""
  
  
  
  
  
  
        UpperCAmelCase_						:      List[str]       ='mock'
  
  
  
  
  
  
  
        def __init__( self				,						*UpperCAmelCase				,						UpperCAmelCase				,						**UpperCAmelCase   )       ->   int:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          super().__init__()
          __snake_case   :				List[str]        =       LocalFileSystem(*UpperCAmelCase				,						**UpperCAmelCase   )
          __snake_case   :				Any        =       Path(UpperCAmelCase   ).resolve().as_posix() + "/"
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self				,						UpperCAmelCase				,						*UpperCAmelCase				,						**UpperCAmelCase   )       ->   Union[str, Any]:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				Union[str, Any]        =       posixpath.join(self.local_root_dir				,						self._strip_protocol(UpperCAmelCase   )   )
          return self._fs.mkdir(UpperCAmelCase				,						*UpperCAmelCase				,						**UpperCAmelCase   )
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self				,						UpperCAmelCase				,						*UpperCAmelCase				,						**UpperCAmelCase   )       ->   List[Any]:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				List[str]        =       posixpath.join(self.local_root_dir				,						self._strip_protocol(UpperCAmelCase   )   )
          return self._fs.makedirs(UpperCAmelCase				,						*UpperCAmelCase				,						**UpperCAmelCase   )
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self				,						UpperCAmelCase   )       ->   Dict:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				Dict        =       posixpath.join(self.local_root_dir				,						self._strip_protocol(UpperCAmelCase   )   )
          return self._fs.rmdir(UpperCAmelCase   )
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self				,						UpperCAmelCase				,						UpperCAmelCase=True				,						*UpperCAmelCase				,						**UpperCAmelCase   )       ->   Optional[Any]:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				Optional[Any]        =       posixpath.join(self.local_root_dir				,						self._strip_protocol(UpperCAmelCase   )   )
          __snake_case   :				List[str]        =       self._fs.ls(UpperCAmelCase				,						detail=UpperCAmelCase				,						*UpperCAmelCase				,						**UpperCAmelCase   )
          if detail:
            return [{**info, "name": info["name"][len(self.local_root_dir   ) :]} for info in out]
          else:
            return [name[len(self.local_root_dir   ) :] for name in out]
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self				,						UpperCAmelCase				,						*UpperCAmelCase				,						**UpperCAmelCase   )       ->   Any:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				Optional[int]        =       posixpath.join(self.local_root_dir				,						self._strip_protocol(UpperCAmelCase   )   )
          __snake_case   :				Dict        =       dict(self._fs.info(UpperCAmelCase				,						*UpperCAmelCase				,						**UpperCAmelCase   )   )
          __snake_case   :				List[Any]        =       out["name"][len(self.local_root_dir   ) :]
          return out
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self				,						UpperCAmelCase				,						UpperCAmelCase				,						*UpperCAmelCase				,						**UpperCAmelCase   )       ->   List[str]:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				Any        =       posixpath.join(self.local_root_dir				,						self._strip_protocol(UpperCAmelCase   )   )
          __snake_case   :				Optional[Any]        =       posixpath.join(self.local_root_dir				,						self._strip_protocol(UpperCAmelCase   )   )
          return self._fs.cp_file(UpperCAmelCase				,						UpperCAmelCase				,						*UpperCAmelCase				,						**UpperCAmelCase   )
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self				,						UpperCAmelCase				,						*UpperCAmelCase				,						**UpperCAmelCase   )       ->   Any:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				Union[str, Any]        =       posixpath.join(self.local_root_dir				,						self._strip_protocol(UpperCAmelCase   )   )
          return self._fs.rm_file(UpperCAmelCase				,						*UpperCAmelCase				,						**UpperCAmelCase   )
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self				,						UpperCAmelCase				,						*UpperCAmelCase				,						**UpperCAmelCase   )       ->   List[str]:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				Optional[Any]        =       posixpath.join(self.local_root_dir				,						self._strip_protocol(UpperCAmelCase   )   )
          return self._fs.rm(UpperCAmelCase				,						*UpperCAmelCase				,						**UpperCAmelCase   )
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self				,						UpperCAmelCase				,						*UpperCAmelCase				,						**UpperCAmelCase   )       ->   Tuple:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				Optional[Any]        =       posixpath.join(self.local_root_dir				,						self._strip_protocol(UpperCAmelCase   )   )
          return self._fs._open(UpperCAmelCase				,						*UpperCAmelCase				,						**UpperCAmelCase   )
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self				,						UpperCAmelCase   )       ->   Optional[Any]:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				Optional[int]        =       posixpath.join(self.local_root_dir				,						self._strip_protocol(UpperCAmelCase   )   )
          return self._fs.created(UpperCAmelCase   )
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self				,						UpperCAmelCase   )       ->   List[Any]:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				int        =       posixpath.join(self.local_root_dir				,						self._strip_protocol(UpperCAmelCase   )   )
          return self._fs.modified(UpperCAmelCase   )
  
  
  
  
  
  
  
        @classmethod
        def 						UpperCAmelCase		( cls				,						UpperCAmelCase   )       ->   Tuple:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				Union[str, Any]        =       stringify_path(UpperCAmelCase   )
          if path.startswith("mock://"   ):
            __snake_case   :				Any        =       path[7:]
          return path
  
  
  
  
  class 				_lowerCamelCase (    __lowerCamelCase    ):
  
  
  
        """simple docstring"""
  
  
  
  
  
  
        UpperCAmelCase_						:      Optional[int]       ='tmp'
        UpperCAmelCase_						:      List[Any]       =None
  
  
  
  
  
  
  
        def __init__( self				,						*UpperCAmelCase				,						**UpperCAmelCase   )       ->   int:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          assert self.tmp_dir is not None, "TmpDirFileSystem.tmp_dir is not set"
          super().__init__(*UpperCAmelCase				,						**UpperCAmelCase				,						local_root_dir=self.tmp_dir				,						auto_mkdir=UpperCAmelCase   )
  
  
  
  
  
  
  
        @classmethod
        def 						UpperCAmelCase		( cls				,						UpperCAmelCase   )       ->   str:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				str        =       stringify_path(UpperCAmelCase   )
          if path.startswith("tmp://"   ):
            __snake_case   :				Optional[int]        =       path[6:]
          return path
  
  
  
  
  
  
  
  @pytest.fixture
  def       lowerCAmelCase__(	) ->    Optional[int]:
    __snake_case   :				int        =       MockFileSystem
    __snake_case   :				Tuple        =       TmpDirFileSystem
    yield
    del _fsspec_registry["mock"]
    del _fsspec_registry["tmp"]
  
  
  
  
  
  
  
  @pytest.fixture
  def       lowerCAmelCase__(	lowercase       :    Dict   ,     lowercase       :    Optional[int]				) ->    Tuple:
    __snake_case   :				Tuple        =       tmp_path_factory.mktemp("mockfs"				)
    return MockFileSystem(local_root_dir=lowercase   ,     auto_mkdir=lowercase				)
  
  
  
  
  
  
  
  @pytest.fixture
  def       lowerCAmelCase__(	lowercase       :    List[Any]   ,     lowercase       :    Tuple				) ->    str:
    __snake_case   :				int        =       tmp_path_factory.mktemp("tmpfs"				)
    with patch.object(lowercase   ,     "tmp_dir"   ,     lowercase				):
      yield TmpDirFileSystem()
  
  
style_context: 
  
  
  
  
  
  from __future__ import annotations
  
  from collections.abc import Callable
  from typing import Generic, TypeVar
  
  _UpperCamelCase       = TypeVar('''T''')
  _UpperCamelCase       = TypeVar('''U''')
  
  
  
  
  class 				_lowerCamelCase (    Generic[T, U]    ):
  
  
  
        """simple docstring"""
  
  
  
  
  
  
        def __init__( self				,						UpperCAmelCase				,						UpperCAmelCase   )       ->   Dict:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				Any        =       key
          __snake_case   :				Tuple        =       val
          __snake_case   :				int        =       0
          __snake_case   :				DoubleLinkedListNode[T, U] | None        =       None
          __snake_case   :				DoubleLinkedListNode[T, U] | None        =       None
  
  
  
  
  
  
  
        def __repr__( self   )       ->   str:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          return "Node: key: {}, val: {}, freq: {}, has next: {}, has prev: {}".format(
              self.key				,						self.val				,						self.freq				,						self.next is not None				,						self.prev is not None   )
  
  
  
  
  class 				_lowerCamelCase (    Generic[T, U]    ):
  
  
  
        """simple docstring"""
  
  
  
  
  
  
        def __init__( self   )       ->   None:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				DoubleLinkedListNode[T, U]        =       DoubleLinkedListNode(UpperCAmelCase				,						UpperCAmelCase   )
          __snake_case   :				DoubleLinkedListNode[T, U]        =       DoubleLinkedListNode(UpperCAmelCase				,						UpperCAmelCase   )
          __snake_case    ,   __snake_case   :				Any        =       self.rear, self.head
  
  
  
  
  
  
  
        def __repr__( self   )       ->   str:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				Union[str, Any]        =       ["DoubleLinkedList"]
          __snake_case   :				List[Any]        =       self.head
          while node.next is not None:
            rep.append(str(UpperCAmelCase   )   )
            __snake_case   :				List[Any]        =       node.next
          rep.append(str(self.rear   )   )
          return ",\n    ".join(UpperCAmelCase   )
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self				,						UpperCAmelCase   )       ->   None:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				Dict        =       self.rear.prev
  
          # All nodes other than self.head are guaranteed to have non-None previous
          assert previous is not None
  
          __snake_case   :				int        =       node
          __snake_case   :				List[str]        =       previous
          __snake_case   :				Optional[int]        =       node
          __snake_case   :				int        =       self.rear
          node.freq += 1
          self._position_node(UpperCAmelCase   )
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self				,						UpperCAmelCase   )       ->   None:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          while node.prev is not None and node.prev.freq > node.freq:
            # swap node with previous node
            __snake_case   :				List[Any]        =       node.prev
  
            __snake_case   :				Dict        =       previous_node.prev
            __snake_case   :				Union[str, Any]        =       node.prev
            __snake_case   :				Union[str, Any]        =       previous_node
            __snake_case   :				int        =       node
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self				,						UpperCAmelCase   )       ->   DoubleLinkedListNode[T, U] | None:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          if node.prev is None or node.next is None:
            return None
  
          __snake_case   :				Optional[int]        =       node.next
          __snake_case   :				Optional[Any]        =       node.prev
          __snake_case   :				Optional[int]        =       None
          __snake_case   :				Any        =       None
          return node
  
  
  
  
  class 				_lowerCamelCase (    Generic[T, U]    ):
  
  
  
        """simple docstring"""
  
  
  
  
  
  
        UpperCAmelCase_						:      dict[Callable[[T], U], LFUCache[T, U]]       ={}
  
  
  
  
  
  
  
        def __init__( self				,						UpperCAmelCase   )       ->   Tuple:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          __snake_case   :				DoubleLinkedList[T, U]        =       DoubleLinkedList()
          __snake_case   :				str        =       capacity
          __snake_case   :				str        =       0
          __snake_case   :				Optional[int]        =       0
          __snake_case   :				Any        =       0
          __snake_case   :				dict[T, DoubleLinkedListNode[T, U]]        =       {}
  
  
  
  
  
  
  
        def __repr__( self   )       ->   str:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          return (
              F"""CacheInfo(hits={self.hits}, misses={self.miss}, """
              F"""capacity={self.capacity}, current_size={self.num_keys})"""
          )
  
  
  
  
  
  
  
        def __contains__( self				,						UpperCAmelCase   )       ->   bool:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          return key in self.cache
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self				,						UpperCAmelCase   )       ->   U | None:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          if key in self.cache:
            self.hits += 1
            __snake_case   :				DoubleLinkedListNode[T, U]        =       self.cache[key]
            __snake_case   :				Union[str, Any]        =       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(UpperCAmelCase   )
            return node.val
          self.miss += 1
          return None
  
  
  
  
  
  
  
        def 						UpperCAmelCase		( self				,						UpperCAmelCase				,						UpperCAmelCase   )       ->   None:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          if key not in self.cache:
            if self.num_keys >= self.capacity:
              # delete first node when over capacity
              __snake_case   :				Optional[Any]        =       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(UpperCAmelCase   ) is not None
              # first_node guaranteed to be in list
  
              del self.cache[first_node.key]
              self.num_keys -= 1
            __snake_case   :				Union[str, Any]        =       DoubleLinkedListNode(UpperCAmelCase				,						UpperCAmelCase   )
            self.list.add(self.cache[key]   )
            self.num_keys += 1
  
          else:
            __snake_case   :				Union[str, Any]        =       self.list.remove(self.cache[key]   )
            assert node is not None  # node guaranteed to be in list
            __snake_case   :				Optional[Any]        =       value
            self.list.add(UpperCAmelCase   )
  
  
  
  
  
  
  
        @classmethod
        def 						UpperCAmelCase		( cls				,						UpperCAmelCase = 128   )       ->   Callable[[Callable[[T], U]], Callable[..., U]]:
  
  
  
  
  
  
          '''simple docstring'''
  
  
  
  
  
  
          def cache_decorator_inner(UpperCAmelCase   ) -> Callable[..., U]:
            def cache_decorator_wrapper(*UpperCAmelCase   ) -> U:
              if func not in cls.decorator_function_to_instance_map:
                __snake_case   :				str        =       LFUCache(UpperCAmelCase   )
  
              __snake_case   :				Dict        =       cls.decorator_function_to_instance_map[func].get(args[0]   )
              if result is None:
                __snake_case   :				Optional[int]        =       func(*UpperCAmelCase   )
                cls.decorator_function_to_instance_map[func].put(args[0]				,						UpperCAmelCase   )
              return result
  
            def cache_info() -> LFUCache[T, U]:
              return cls.decorator_function_to_instance_map[func]
  
            setattr(UpperCAmelCase				,						"cache_info"				,						UpperCAmelCase   )  # noqa: B010
  
            return cache_decorator_wrapper
  
          return cache_decorator_inner
  
  
  if __name__ == "__main__":
       import doctest
  
       doctest.testmod()
  
  