code: def _build_paths_from_predecessors(sources, target, pred):
      """Compute all simple paths to target, given the predecessors found in
      pred, terminating when any source in sources is found.
  
      Parameters
      ----------
      sources : set
         Starting nodes for path.
  
      target : node
         Ending node for path.
  
      pred : dict
         A dictionary of predecessor lists, keyed by node
  
      Returns
      -------
      paths : generator of lists
          A generator of all paths between source and target.
  
      Raises
      ------
      NetworkXNoPath
          If `target` cannot be reached from `source`.
  
      Notes
      -----
      There may be many paths between the sources and target.  If there are
      cycles among the predecessors, this function will not produce all
      possible paths because doing so would produce infinitely many paths
      of unbounded length -- instead, we only produce simple paths.
  
      See Also
      --------
      shortest_path
      single_source_shortest_path
      all_pairs_shortest_path
      all_shortest_paths
      bellman_ford_path
      """
      if target not in pred:
          raise nx.NetworkXNoPath(
              f"Target {target} cannot be reached from given sources"
          )
  
      seen = {target}
      stack = [[target, 0]]
      top = 0
      while top >= 0:
          node, i = stack[top]
          if node in sources:
              yield [p for p, n in reversed(stack[: top + 1])]
          if len(pred[node]) > i:
              stack[top][1] = i + 1
              next = pred[node][i]
              if next in seen:
                  continue
              else:
                  seen.add(next)
              top += 1
              if top == len(stack):
                  stack.append([next, 0])
              else:
                  stack[top][:] = [next, 0]
          else:
              seen.discard(node)
              top -= 1
  
file_path: networkx/networkx/algorithms/shortest_paths/generic.py
imports: import warnings
  import networkx
label_desc: Use image node_id 8 for calling a global function with example usage: _build_paths_from_predecessors(sources, target, pred) without return types