code: def _remove_unused_links(repo):
      used = [
          out.fspath
          for out in repo.index.outs
          if out.protocol == "local"
      ]
      unused = repo.state.get_unused_links(used, repo.fs)
      ret = [_fspath_dir(u) for u in unused]
      repo.state.remove_links(unused, repo.fs)
      return ret
  
file_path: dvc/dvc/repo/checkout.py
imports: import os
  from typing import TYPE_CHECKING, Dict, List
  from dvc.exceptions import CheckoutError, CheckoutErrorSuggestGit, DvcException, NoOutputOrStageError
  from dvc.log import logger
  from dvc.ui import ui
  from dvc.utils import relpath
  from .None import locked
label_desc: Use image node_id 2 for calling a global function with example usage: _remove_unused_links(repo) and returns: ret