code: def _collect_targets(repo, target, outs):
      if not target:
          return []
  
      pairs = repo.stage.collect_granular(target)
      if not outs:
          return [stage.addressing for stage, _ in pairs]
  
      targets = []
  
      outs_trie = repo.index.outs_trie
      for stage, path in pairs:
          if not path:
              targets.extend([str(out) for out in stage.outs])
              continue
  
          for out in outs_trie.itervalues(prefix=repo.fs.parts(path)):
              targets.extend(str(out))
  
      return targets
  
file_path: dvc/dvc/commands/dag.py
imports: from typing import TYPE_CHECKING
  from dvc.cli import formatter
  from dvc.cli.command import CmdBase
  from dvc.cli.utils import append_doc_link
  from dvc.ui import ui
label_desc: Use image node_id 5 for calling a global function with example usage: _collect_targets(repo, target, outs) and returns: targets, list, unknown