code: def _bfs_for_reachable_nodes(target_nodes, name_to_input_name):
      """Breadth first search for reachable nodes from target nodes."""
      nodes_to_keep = set()
      # Breadth first search to find all the nodes that we should keep.
      next_to_visit = list(target_nodes)
      while next_to_visit:
          node = next_to_visit[0]
          del next_to_visit[0]
          if node in nodes_to_keep:
              # Already visited this node.
              continue
          nodes_to_keep.add(node)
          if node in name_to_input_name:
              next_to_visit += name_to_input_name[node]
      return nodes_to_keep
  
file_path: tensorflow/tensorflow/python/framework/graph_util_impl.py
imports: import copy
  import re
  from tensorflow.core.framework import graph_pb2
  from tensorflow.core.framework import node_def_pb2
  from tensorflow.python.framework import _proto_comparators
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.util import deprecation
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 7 for calling a global function with example usage: _bfs_for_reachable_nodes(target_nodes, name_to_input_name) and returns: nodes_to_keep