def verify_model_outputs(
    pytorch_model, coreml_model, input_value, snr_thresh=20.0, psnr_thresh=23.0
):
    """
    This utility functions does the following checks:
    (1) Verify the output of the coreml model has the same shape of the PyTorch model
    (2) The PyTorch and coreml model have the same numerical outputs
    """
    # Validate the output shape / type
    ref_output = pytorch_model(input_value)
    output = coreml_model._mil_program.functions["main"].outputs[0]

    assert ref_output.shape == output.shape

    # Cannot run predict on linux
    if sys.platform == "linux":
        return

    # Validate that the coreml model produces correct outputs
    pytorch_model.eval()
    pytorch_output = pytorch_model(input_value)
    ref_output = [pytorch_output.detach().cpu().numpy()]
    mlmodel_output_names = [str(x) for x in coreml_model.output_description]
    ref_output_dict = dict(zip(mlmodel_output_names, ref_output))

    coreml_input_value = {"input_1": input_value.detach().numpy()}
    output_dict = coreml_model.predict(coreml_input_value)

    assert len(output_dict) == len(ref_output_dict)

    for key in output_dict:
        coreml_out = output_dict[key].flatten()
        ref_out = ref_output_dict[key].flatten()
        snr, psnr = compute_SNR_and_PSNR(coreml_out, ref_out)
        print(f"SNR: {snr}, PSNR: {psnr}")
        assert snr > snr_thresh
        assert psnr > psnr_thresh

    This utility functions does the following checks:
    (1) Verify the output of the coreml model has the same shape of the PyTorch model
    (2) The PyTorch and coreml model have the same numerical outputs
    
coremltools/test/optimize/torch/conversion/conversion_utils.py