def run_compare_tf2(
    model,
    input_dict,
    output_names,
    inputs_for_conversion=None,
    compute_unit=ct.ComputeUnit.CPU_ONLY,
    frontend_only=False,
    frontend="tensorflow",
    backend=("neuralnetwork", "fp32"),
    debug=False,
    atol=1e-04,
    rtol=1e-05,
    minimum_deployment_target=None,
):
    """
    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.
    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.
    debug: bool
        If True, print verbose information and plot intermediate graphs.
    atol: float
        The absolute tolerance parameter.
    rtol: float
        The relative tolerance parameter.
    minimum_deployment_target: coremltools.target enumeration
        The spec version for the mlmodel
    """
    # Infinite upper-bound not allowed in mlprogram.
    symbolic_upper_bound = 20 if backend[0] == "mlprogram" else -1

    inputs = []
    if inputs_for_conversion is None:
        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]
            shape = [
                RangeDim(upper_bound=symbolic_upper_bound) if s is None or s == -1 else s
                for s in list(t.get_shape())
            ]
            inputs.append(TensorType(name=name, shape=shape, dtype=t.dtype.as_numpy_dtype))
    else:
        inputs = inputs_for_conversion

    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 comparison
    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)}

    mlmodel = ct_convert(
        model,
        source=frontend,
        inputs=inputs,
        outputs=outputs,
        convert_to=backend,
        debug=debug,
        compute_units=compute_unit,
        minimum_deployment_target=minimum_deployment_target,
    )

    for k,v in input_dict.items():
        if isinstance(v, np.ndarray) and issubclass(v.dtype.type, np.integer):
            input_dict[k] = v.astype(float) # Core ML only accepts floats

    if frontend_only or _macos_version() < (10, 13) \
       or (mlmodel.is_package and _macos_version() < (12, 0)):
        return mlmodel._spec, mlmodel, input_dict, None

    pred = None
    if not coremltoolsutils._has_custom_layer(mlmodel._spec):
        pred = compare_backend(
            mlmodel,
            input_dict,
            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 mlmodel._spec, mlmodel, input_dict, pred

    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.
    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.
    debug: bool
        If True, print verbose information and plot intermediate graphs.
    atol: float
        The absolute tolerance parameter.
    rtol: float
        The relative tolerance parameter.
    minimum_deployment_target: coremltools.target enumeration
        The spec version for the mlmodel
    
coremltools/converters/mil/frontend/tensorflow2/test/testing_utils.py