code: def run_compare_tf_keras(
      model,
      input_values,
      inputs_for_conversion=None,
      compute_unit=ct.ComputeUnit.CPU_ONLY,
      frontend_only=False,
      frontend="tensorflow",
      backend=("neuralnetwork", "fp32"),
      atol=1e-04,
      rtol=1e-05,
  ):
      """
      Parameters
      ----------
      model: TensorFlow 2.x model
          TensorFlow 2.x model annotated with @tf.function.
      input_values: list of np.array
          List of input values in the same order as the input signature.
      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.
      compute_unit: Enum[ct.ComputeUnit]
          Compute unit for the coreml model
      frontend_only: bool
          If True, skip the prediction call, only validate conversion.
      frontend: str
          Frontend to convert from.
      backend: str
          Backend to convert to.
      atol: float
          The absolute tolerance parameter.
      rtol: float
          The relative tolerance parameter.
      """
      mlmodel = ct_convert(
          model,
          inputs=inputs_for_conversion,
          source=frontend,
          convert_to=backend,
          compute_units=compute_unit,
      )
  
      # assumes conversion preserve the i/o names
      proto = mlmodel._spec
      inputs = [i.name.split(":")[0].strip() for i in model.inputs]
      outputs = [str(o.name) for o in proto.description.output]
  
      # get tf.keras model output as reference and run comparison
      keras_outputs = model(input_values)
      if not isinstance(keras_outputs, list):
          keras_outputs = [keras_outputs]
      ref = [output.numpy() for output in keras_outputs]
      expected_outputs = {n: v for n, v in zip(outputs, ref)}
      input_key_values = {n: v for n, v in zip(inputs, input_values)}
  
      if (
          frontend_only
          or _macos_version() < (10, 13)
          or (mlmodel.is_package and _macos_version() < (12, 0))
      ):
          return proto, mlmodel, input_key_values, None
  
      pred = None
      if not coremltoolsutils._has_custom_layer(proto):
          pred = compare_backend(
              mlmodel,
              input_key_values,
              expected_outputs,
              atol=atol,
              rtol=rtol,
              also_compare_shapes=True,
              dtype=backend[1],
          )
      else:
          print(
              "Skipping model prediction as it has a custom nn layer!"
          )
      return proto, mlmodel, input_key_values, pred
  
file_path: coremltools/coremltools/converters/mil/frontend/tensorflow2/test/testing_utils.py
imports: import numpy
  import pytest
  from tensorflow.python.framework import dtypes
  import coremltools
  import coremltools.models.utils
  from coremltools.converters.mil.frontend.tensorflow.test.testing_utils import TensorFlowBaseTest, get_tf_node_names
  from coremltools.converters.mil.input_types import RangeDim, TensorType
  from coremltools.converters.mil.testing_utils import compare_backend, ct_convert, validate_minimum_deployment_target
  from coremltools.models.utils import _macos_version
label_desc: Use image node_id 3 for calling a global function with example usage: run_compare_tf_keras(model, input_values, inputs_for_conversion, compute_unit, frontend_only, frontend, backend, atol, rtol) and returns: proto,  mlmodel,  input_key_values,  pred, proto,  mlmodel,  input_key_values,  None