code: def _collect_vars(repo, params, stages=None) -> Dict:
      vars_params: Dict[str, Dict] = defaultdict(dict)
  
      for stage in repo.index.stages:
          if isinstance(stage, PipelineStage) and stage.tracked_vars:
              if stages and stage.addressing not in stages:
                  continue
              for file, vars_ in stage.tracked_vars.items():
                  # `params` file are shown regardless of `tracked` or not
                  # to reduce noise and duplication, they are skipped
  
                  # `file` is relative
                  abspath = repo.fs.abspath(file)
                  repo_path = repo.dvcfs.from_os_path(abspath)
                  if repo_path in params:
                      continue
  
                  vars_params[repo_path].update(vars_)
      return dict(vars_params)
  
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 4 for calling a global function with example usage: _collect_vars(repo, params, stages) and returns: dict