code: def tf_graph_to_mlmodel(
      graph,
      feed_dict,
      output_nodes,
      frontend="tensorflow",
      backend=("neuralnetwork", "fp32"),
      compute_unit=ct.ComputeUnit.CPU_ONLY,
      inputs_for_conversion=None,
      minimum_deployment_target=None,
  ):
      """
      Parameters
      ----------
      graph: tf.Graph
          TensorFlow 1.x model in tf.Graph format.
      feed_dict: dict of {tf.placeholder -> np.array or python primitive)
          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.
      compute_unit: Enum[ct.ComputeUnit].
          Compute unit for the coreml model
      inputs_for_conversion: list of coremltools.TensorType() or coremltools.ImageType() objects
          Defaults to None. It is passed as is to the "inputs" argument of the converter.
      minimum_deployment_target : coremltools.target enumeration
          It set the minimum_deployment_target argument in the coremltools.convert function.
      -----------
      Returns MLModel, 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())
      }
  
      if inputs_for_conversion is None and backend[0] == "mlprogram":
          # As mlprogram by default use a small upper-bound for dynamic shapes, set a larger one here
          # to avoid test failures.
          has_dynamic_shape = False
          input_types = []
          for input_placeholder in list(feed_dict.keys()):
              input_shape = [
                  ct.RangeDim(upper_bound=64)
                  if dim.value is None
                  else dim.value
                  for dim in input_placeholder.shape
              ]
              input_types.append(
                  ct.TensorType(
                      name=input_placeholder.name.split(":")[0],
                      shape=input_shape,
                  )
              )
              if any(
                  [dim.value is None for dim in input_placeholder.shape]
              ):
                  has_dynamic_shape = True
          if has_dynamic_shape:
              inputs_for_conversion = input_types
  
      mlmodel = ct_convert(
          graph,
          inputs=inputs_for_conversion,
          outputs=output_names,
          source=frontend,
          convert_to=backend,
          compute_units=compute_unit,
          minimum_deployment_target=minimum_deployment_target,
      )
  
      return mlmodel, input_values, output_names, output_nodes
  
imports: import os
  import tempfile
  import numpy
  import pytest
  import coremltools.models.utils
  from coremltools._deps import _HAS_TF_2
  from coremltools.converters.mil.testing_reqs import ct
  from coremltools.converters.mil.testing_utils import compare_backend, ct_convert, validate_minimum_deployment_target
  from tensorflow.python.framework import dtypes
  from tensorflow.python.keras.saving import saving_utils
  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_mlmodel(graph, feed_dict, output_nodes, frontend, backend, compute_unit, inputs_for_conversion, minimum_deployment_target) and returns: mlmodel,  input_values,  output_names,  output_nodes