class_docstr: Access a remote Hugging Face Hub repository as if were a local file system.
  
  Args:
      token (`str`, *optional*):
          Authentication token, obtained with [`HfApi.login`] method. Will default to the stored token.
  
  Usage:
  
  ```python
  >>> from huggingface_hub import HfFileSystem
  
  >>> fs = HfFileSystem()
  
  >>> # List files
  >>> fs.glob("my-username/my-model/*.bin")
  ['my-username/my-model/pytorch_model.bin']
  >>> fs.ls("datasets/my-username/my-dataset", detail=False)
  ['datasets/my-username/my-dataset/.gitattributes', 'datasets/my-username/my-dataset/README.md', 'datasets/my-username/my-dataset/data.json']
  
  >>> # Read/write files
  >>> with fs.open("my-username/my-model/pytorch_model.bin") as f:
  ...     data = f.read()
  >>> with fs.open("my-username/my-model/pytorch_model.bin", "wb") as f:
  ...     f.write(data)
  ```
class_docstr_tok: ["Access","a","remote","Hugging","Face","Hub","repository","as","if","were","a","local","file","system",".","Args",":","token","(","`","str","`",",","*","optional","*",")",":","Authentication","token",",","obtained","with","[","`","HfApi.login","`","]","method",".","Will","default","to","the","stored","token",".","Usage",":","``","`","python",">",">",">","from","huggingface_hub","import","HfFileSystem",">",">",">","fs","=","HfFileSystem","(",")",">",">",">","#","List","files",">",">",">","fs.glob","(","``","my-username\/my-model\/","*",".bin","''",")","[","'my-username\/my-model\/pytorch_model.bin","'","]",">",">",">","fs.ls","(","``","datasets\/my-username\/my-dataset","''",",","detail=False",")","[","'datasets\/my-username\/my-dataset\/.gitattributes","'",",","'datasets\/my-username\/my-dataset\/README.md","'",",","'datasets\/my-username\/my-dataset\/data.json","'","]",">",">",">","#","Read\/write","files",">",">",">","with","fs.open","(","``","my-username\/my-model\/pytorch_model.bin","''",")","as","f",":","...","data","=","f.read","(",")",">",">",">","with","fs.open","(","``","my-username\/my-model\/pytorch_model.bin","''",",","``","wb","''",")","as","f",":","...","f.write","(","data",")","``","`"]
code: def resolve_path(
      self, path: str, revision: Optional[str] = None
  ) -> HfFileSystemResolvedPath:
      def _align_revision_in_path_with_revision(
          revision_in_path: Optional[str], revision: Optional[str]
      ) -> Optional[str]:
          if revision is not None:
              if (
                  revision_in_path is not None
                  and revision_in_path != revision
              ):
                  raise ValueError(
                      f'Revision specified in path ("{revision_in_path}") and in `revision` argument ("{revision}")'
                      " are not the same."
                  )
          else:
              revision = revision_in_path
          return revision
  
      path = self._strip_protocol(path)
      if not path:
          # can't list repositories at root
          raise NotImplementedError(
              "Access to repositories lists is not implemented."
          )
      elif path.split("/")[0] + "/" in REPO_TYPES_URL_PREFIXES.values():
          if "/" not in path:
              # can't list repositories at the repository type level
              raise NotImplementedError(
                  "Access to repositories lists is not implemented."
              )
          repo_type, path = path.split("/", 1)
          repo_type = REPO_TYPES_MAPPING[repo_type]
      else:
          repo_type = REPO_TYPE_MODEL
      if path.count("/") > 0:
          if "@" in path:
              repo_id, revision_in_path = path.split("@", 1)
              if "/" in revision_in_path:
                  match = SPECIAL_REFS_REVISION_REGEX.search(
                      revision_in_path
                  )
                  if match is not None and revision in (
                      None,
                      match.group(),
                  ):
                      # Handle `refs/convert/parquet` and PR revisions separately
                      path_in_repo = SPECIAL_REFS_REVISION_REGEX.sub(
                          "", revision_in_path
                      ).lstrip("/")
                      revision_in_path = match.group()
                  else:
                      (
                          revision_in_path,
                          path_in_repo,
                      ) = revision_in_path.split("/", 1)
              else:
                  path_in_repo = ""
              revision = _align_revision_in_path_with_revision(
                  unquote(revision_in_path), revision
              )
              (
                  repo_and_revision_exist,
                  err,
              ) = self._repo_and_revision_exist(
                  repo_type, repo_id, revision
              )
              if not repo_and_revision_exist:
                  _raise_file_not_found(path, err)
          else:
              revision_in_path = None
              repo_id_with_namespace = "/".join(path.split("/")[:2])
              path_in_repo_with_namespace = "/".join(
                  path.split("/")[2:]
              )
              repo_id_without_namespace = path.split("/")[0]
              path_in_repo_without_namespace = "/".join(
                  path.split("/")[1:]
              )
              repo_id = repo_id_with_namespace
              path_in_repo = path_in_repo_with_namespace
              (
                  repo_and_revision_exist,
                  err,
              ) = self._repo_and_revision_exist(
                  repo_type, repo_id, revision
              )
              if not repo_and_revision_exist:
                  if isinstance(
                      err, (RepositoryNotFoundError, HFValidationError)
                  ):
                      repo_id = repo_id_without_namespace
                      path_in_repo = path_in_repo_without_namespace
                      (
                          repo_and_revision_exist,
                          _,
                      ) = self._repo_and_revision_exist(
                          repo_type, repo_id, revision
                      )
                      if not repo_and_revision_exist:
                          _raise_file_not_found(path, err)
                  else:
                      _raise_file_not_found(path, err)
      else:
          repo_id = path
          path_in_repo = ""
          if "@" in path:
              repo_id, revision_in_path = path.split("@", 1)
              revision = _align_revision_in_path_with_revision(
                  unquote(revision_in_path), revision
              )
          else:
              revision_in_path = None
          repo_and_revision_exist, _ = self._repo_and_revision_exist(
              repo_type, repo_id, revision
          )
          if not repo_and_revision_exist:
              raise NotImplementedError(
                  "Access to repositories lists is not implemented."
              )
  
      revision = revision if revision is not None else DEFAULT_REVISION
      return HfFileSystemResolvedPath(
          repo_type,
          repo_id,
          revision,
          path_in_repo,
          _raw_revision=revision_in_path,
      )
  
imports: import copy
  import os
  import re
  import tempfile
  from collections import deque
  from dataclasses import dataclass, field
  from datetime import datetime
  from itertools import chain
  from typing import Any, Dict, List, NoReturn, Optional, Tuple, Union
  from urllib.parse import quote, unquote
  import fsspec
  from ._commit_api import CommitOperationCopy, CommitOperationDelete
  from .constants import DEFAULT_REVISION, ENDPOINT, REPO_TYPE_MODEL, REPO_TYPES_MAPPING, REPO_TYPES_URL_PREFIXES
  from .file_download import hf_hub_url
  from .hf_api import HfApi, LastCommitInfo, RepoFile
  from .utils import EntryNotFoundError, HFValidationError, RepositoryNotFoundError, RevisionNotFoundError, hf_raise_for_status, http_backoff
label_desc: Use image node_id 3 for calling the HfFileSystem obj's underlying member method code with example usage: obj.resolve_path(path, revision) and returns: HfFileSystemResolvedPath, revision