code: def collect_pipeline(
      stage: "Stage", graph: "DiGraph"
  ) -> Iterator["Stage"]:
      import networkx as nx
  
      pipeline = get_pipeline(get_pipelines(graph), stage)
      if not pipeline:
          return iter([])
  
      return nx.dfs_postorder_nodes(pipeline, stage)
  
file_path: dvc/dvc/repo/graph.py
imports: from typing import TYPE_CHECKING, Any, Iterator, List, Optional, Set, TypeVar
  from dvc.fs import localfs
  from dvc.utils.fs import path_isin
label_desc: Use image node_id 5 for calling a global function with example usage: collect_pipeline(stage, graph) and returns: nx, iter