code: def tf_graph_to_proto(
      graph,
      feed_dict,
      output_nodes,
      frontend="tensorflow",
      backend="nn_proto",
  ):
      """
      Parameters
      ----------
      graph: tf.Graph
          TensorFlow 1.x model in tf.Graph format.
      feed_dict: dict of (tf.placeholder, np.array)
          Dict of placeholder and value pairs representing inputs.
      output_nodes: tf.node or list[tf.node]
          List of names representing outputs.
      frontend: str
          Frontend to convert from.
      backend: str
          Backend to convert to.
      -----------
      Returns Proto, Input Values, Output Names
      """
      if isinstance(output_nodes, tuple):
          output_nodes = list(output_nodes)
      if not isinstance(output_nodes, list):
          output_nodes = [output_nodes]
  
      # Convert TF graph.
      input_names = get_tf_node_names(
          list(feed_dict.keys()), mode="inputs"
      )
      output_names = get_tf_node_names(output_nodes, mode="outputs")
      input_values = {
          name: val
          for name, val in zip(input_names, feed_dict.values())
      }
  
      inputs = [
          TensorType(name=input_name) for input_name in input_names
      ]
      mlmodel = converter.convert(
          graph,
          inputs=inputs,
          outputs=output_names,
          source=frontend,
          convert_to=backend,
      )
  
      proto = mlmodel.get_spec()
      return proto, input_values, output_names, output_nodes
  
file_path: turicreate/src/external/coremltools_wrap/coremltools/coremltools/converters/mil/frontend/tensorflow/test/testing_utils.py
imports: import six
  from coremltools import TensorType
  import pytest
  from coremltools.converters.mil.testing_utils import compare_shapes, compare_backend
  from coremltools.converters.mil.testing_reqs import converter
  from tensorflow.python.framework import dtypes
  import tempfile
  import os
  from tensorflow.python.tools.freeze_graph import freeze_graph
label_desc: Use image node_id 4 for calling a global function with example usage: tf_graph_to_proto(graph, feed_dict, output_nodes, frontend, backend) and returns: proto,  input_values,  output_names,  output_nodes