code: def _gather_params(
      repo: "Repo",
      targets: Union[List[str], Dict[str, List[str]], None] = None,
      deps_only: bool = False,
      stages: Optional[List[str]] = None,
      on_error: str = "return",
  ):
      assert on_error in ("raise", "return", "ignore")
  
      # `files` is a repo-relative posixpath that can be passed to DVCFileSystem
      # It is absolute, i.e. has a root_marker `/` in front which we strip when returning
      # the result and convert to appropriate repo-relative os.path.
      files_keypaths = _collect_params(
          repo,
          targets=targets,
          stages=stages,
          deps_only=deps_only,
          default_file=ParamsDependency.DEFAULT_PARAMS_FILE,
      )
  
      data: Dict[str, FileResult] = {}
  
      fs = repo.dvcfs
      for fs_path, result in _read_params(
          fs, files_keypaths, cache=True
      ):
          repo_path = fs_path.lstrip(fs.root_marker)
          repo_os_path = os.sep.join(fs.parts(repo_path))
          if not isinstance(result, Exception):
              data.update({repo_os_path: FileResult(data=result)})
              continue
  
          if on_error == "raise":
              raise result
          if on_error == "return":
              data.update({repo_os_path: FileResult(error=result)})
  
      if not (stages or targets):
          data.update(
              {
                  path: FileResult(data=result)
                  for path, result in _collect_vars(repo, data).items()
              }
          )
      return data
  
file_path: dvc/dvc/repo/params/show.py
imports: import os
  from collections import defaultdict
  from itertools import chain
  from typing import TYPE_CHECKING, Any, Dict, Iterator, List, Optional, Tuple, Union
  from dvc.dependency.param import ParamsDependency, read_param_file
  from dvc.log import logger
  from dvc.repo.metrics.show import FileResult, Result
  from dvc.stage import PipelineStage
  from dvc.utils import as_posix, expand_paths
  from dvc.utils.collections import ensure_list
label_desc: Use image node_id 6 for calling a global function with example usage: _gather_params(repo, targets, deps_only, stages, on_error) and returns: data