code: def frozen_default_graph_def(input_node_names, output_node_names):
      """Return frozen and simplified graph_def of default graph."""
  
      sess = tf.get_default_session()
      if sess is None:
          raise RuntimeError("Default session not registered.")
  
      input_graph_def = tf.get_default_graph().as_graph_def()
      if len(input_graph_def.node) == 0:
          raise RuntimeError(
              "Default graph is empty. Is it possible your model wasn't constructed or is in a different graph?"
          )
  
      pruned_graph = tf.graph_util.remove_training_nodes(
          input_graph_def,
          protected_nodes=(output_node_names + input_node_names),
      )
      pruned_graph = tf.graph_util.extract_sub_graph(
          pruned_graph, output_node_names
      )
  
      # remove explicit device assignments
      for node in pruned_graph.node:
          node.device = ""
  
      all_variable_names = [v.op.name for v in tf.global_variables()]
      output_graph_def = tf.graph_util.convert_variables_to_constants(
          sess=sess,
          input_graph_def=pruned_graph,
          output_node_names=output_node_names,
          variable_names_whitelist=all_variable_names,
      )
  
      return output_graph_def
  
file_path: lucid/lucid/modelzoo/util.py
imports: from __future__ import absolute_import, division, print_function
  import tensorflow
  import json
  from google.protobuf.message import DecodeError
  import logging
  import warnings
  from collections import defaultdict
  from itertools import chain
  from lucid.misc.io import load
  from lucid.misc.io.saving import ClarityJSONEncoder
label_desc: Use image node_id 4 for calling a global function with example usage: frozen_default_graph_def(input_node_names, output_node_names) and returns: output_graph_def