code: def build_outs_graph(graph, outs_trie):
      import networkx as nx
  
      outs_graph = nx.DiGraph()
  
      outs_graph.add_nodes_from(outs_trie.values())
      for stage in graph.nodes():
          if stage.is_repo_import:
              continue
          if stage.is_db_import:
              continue
          for dep in stage.deps:
              dep_key = dep.fs.parts(dep.fs_path)
              overlapping = [
                  n.value for n in outs_trie.prefixes(dep_key)
              ]
              if outs_trie.has_subtrie(dep_key):
                  overlapping.extend(outs_trie.values(prefix=dep_key))
  
              for from_out in stage.outs:
                  outs_graph.add_edges_from(
                      (from_out, out) for out in overlapping
                  )
      return outs_graph
  
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 8 for calling a global function with example usage: build_outs_graph(graph, outs_trie) and returns: outs_graph