code: def to_relpath(fs: "FileSystem", root_dir: str, d: Result) -> Result:
      relpath = fs.relpath
      cwd = fs.getcwd()
  
      start = relpath(cwd, root_dir)
      data = d.get("data")
      if data is not None:
          d["data"] = {
              relpath(path, start): result
              for path, result in data.items()
          }
      return d
  
imports: import os
  from itertools import chain
  from typing import TYPE_CHECKING, Any, Dict, Iterable, Iterator, List, Optional, Tuple, TypedDict, Union
  from funcy import ldistinct
  from scmrepo.exceptions import SCMError
  from dvc.log import logger
  from dvc.scm import NoSCMError
  from dvc.utils import as_posix, expand_paths
  from dvc.utils.collections import ensure_list
  from dvc.utils.serialize import load_path
label_desc: Use image node_id 7 for calling a global function with example usage: to_relpath(fs, root_dir, d) and returns: d