code: def frozen_default_graph_def(input_node_names, output_node_names):
    
  
    sess = tf.get_default_session()
    input_graph_def = tf.get_default_graph().as_graph_def()
  
    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
docs: Return frozen and simplified graph_def of default graph.