code: def extract_sub_graph(graph_def, dest_nodes):
      """Extract the subgraph that can reach any of the nodes in 'dest_nodes'.
      Args:
        graph_def: A graph_pb2.GraphDef proto.
        dest_nodes: A list of strings specifying the destination node names.
      Returns:
        The GraphDef of the sub-graph.
      Raises:
        TypeError: If 'graph_def' is not a graph_pb2.GraphDef proto.
      """
  
      if not isinstance(graph_def, graph_pb2.GraphDef):
          invalidInputError(
              False, "graph_def must be a graph_pb2.GraphDef proto."
          )
  
      if isinstance(dest_nodes, six.string_types):
          invalidInputError(False, "dest_nodes must be a list.")
  
      (
          name_to_input_name,
          name_to_node,
          name_to_seq_num,
      ) = _extract_graph_summary(graph_def)
      _assert_nodes_are_present(name_to_node, dest_nodes)
  
      nodes_to_keep = _bfs_for_reachable_nodes(
          dest_nodes, name_to_input_name
      )
  
      nodes_to_keep_list = sorted(
          list(nodes_to_keep), key=lambda n: name_to_seq_num[n]
      )
      # Now construct the output GraphDef
      out = graph_pb2.GraphDef()
      for n in nodes_to_keep_list:
          out.node.extend([copy.deepcopy(name_to_node[n])])
      out.library.CopyFrom(graph_def.library)
      out.versions.CopyFrom(graph_def.versions)
  
      return out
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import copy
  import re
  import six
  from tensorflow.core.framework import attr_value_pb2
  from tensorflow.core.framework import graph_pb2
  from tensorflow.core.framework import node_def_pb2
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.util import deprecation
  from tensorflow.python.util.tf_export import tf_export
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 7 for calling a global function with example usage: extract_sub_graph(graph_def, dest_nodes) and returns: out