code: def run_compare_tf2(
      model,
      input_dict,
      output_names,
      use_cpu_only=False,
      frontend_only=False,
      frontend="tensorflow",
      backend="nn_proto",
      debug=False,
      atol=1e-04,
      rtol=1e-05,
  ):
      """
      Parameters
      ----------
      model: list of tf.ConcreteFunction
          List of TensorFlow 2.x concrete functions.
      input_dict: dict of (str, np.array)
          Dict of name and value pairs representing inputs.
      output_names: list of str
          List of output node names.
      use_cpu_only: bool
          If true, use CPU only for prediction, otherwise, use GPU also.
      frontend_only: bool
          If true, skip the prediction call, only validate conversion.
      frontend: str
          Frontend to convert from.
      backend: str
          Backend to convert to.
      debug: bool
          If true, print verbose information and plot intermediate graphs.
      atol: float
          The absolute tolerance parameter.
      rtol: float
          The relative tolerance parameter.
      """
      inputs = []
      cf_inputs = [
          t for t in model[0].inputs if t.dtype != dtypes.resource
      ]
      for t in cf_inputs:
          name = get_tf_node_names(t.name)[0]
          inputs.append(
              TensorType(name=name, shape=list(t.get_shape()))
          )
      outputs = []
      for t in output_names:
          name = get_tf_node_names(t)[0]
          outputs.append(name)
  
      # get TensorFlow 2.x output as reference and run comparision
      tf_input_values = [tf.constant(t) for t in input_dict.values()]
      tf_outputs = model[0](*tf_input_values)
      if isinstance(tf_outputs, (tuple, list)):
          ref = [t.numpy() for t in tf_outputs]
      else:
          ref = [tf_outputs.numpy()]
      expected_outputs = {n: v for n, v in zip(outputs, ref)}
  
      proto = converter.convert(
          model,
          source=frontend,
          inputs=inputs,
          outputs=outputs,
          convert_to=backend,
          debug=debug,
      ).get_spec()
  
      if frontend_only:
          return
  
      compare_backend(
          proto,
          input_dict,
          expected_outputs,
          use_cpu_only,
          atol=atol,
          rtol=rtol,
          also_compare_shapes=True,
      )
  
      return proto
  
file_path: turicreate/src/external/coremltools_wrap/coremltools/coremltools/converters/mil/frontend/tensorflow2/test/testing_utils.py
imports: from coremltools.converters.mil.testing_reqs import converter
  import pytest
  from coremltools.converters.mil.frontend.tensorflow.test.testing_utils import get_tf_node_names
  from coremltools.converters.mil.input_types import TensorType
  from coremltools.converters.mil.testing_utils import compare_backend
  from tensorflow.python.framework import dtypes
label_desc: Use image node_id 2 for calling a global function with example usage: run_compare_tf2(model, input_dict, output_names, use_cpu_only, frontend_only, frontend, backend, debug, atol, rtol) and returns: proto