code: def _switch_fs(
      repo: "Repo",
      rev: str,
      repo_root_parts: Tuple[str, ...],
      cwd_parts: Tuple[str, ...],
  ):
      from dvc.fs import GitFileSystem, LocalFileSystem
  
      if rev == "workspace":
          logger.trace("switching fs to workspace")
          repo.fs = LocalFileSystem(url=repo.root_dir)
          return
  
      logger.trace("switching fs to revision %s", rev[:7])
      assert isinstance(repo.scm, Git)
      fs = GitFileSystem(scm=repo.scm, rev=rev)
      root_dir = repo.fs.join("/", *repo_root_parts)
      if not fs.exists(root_dir):
          raise NotDvcRepoError(
              f"Commit '{rev[:7]}' does not contain a DVC repo"
          )
  
      repo.fs = fs
      repo.root_dir = root_dir
      repo.dvc_dir = fs.join(root_dir, repo.DVC_DIR)
      repo._reset()
  
      if cwd_parts:
          cwd = repo.fs.join("/", *cwd_parts)
          repo.fs.chdir(cwd)
  
file_path: dvc/dvc/repo/brancher.py
imports: from contextlib import contextmanager
  from typing import TYPE_CHECKING, Iterator, Optional, Tuple
  from scmrepo.git import Git
  from dvc.exceptions import NotDvcRepoError
  from dvc.log import logger
  from dvc.scm import iter_revs
label_desc: Use image node_id 2 for calling a global function with example usage: _switch_fs(repo, rev, repo_root_parts, cwd_parts) without return types