code: def compare_models(
      full_precision_model, quantized_model, sample_data
  ):
      """
      Utility function to compare the performance of a full precision vs quantized model
  
      full_precision_model: MLModel
          The full precision model with float32 weights
  
      quantized_model: MLModel
          Quantized version of the model with quantized weights
  
      sample_data: str | [dict]
          Data used to characterize performance of the quantized model in
          comparison to the full precision model. Either a list of sample input
          dictionaries or an absolute path to a directory containing images.
          Path to a directory containing images is only valid for models with
          one image input. For all other models a list of sample inputs must be
          provided.
  
      :return:
          None. Performance metrics are printed out
      """
      emessage = """
      Invalid sample data provided. Only a list of dictionaries
      containing sample data or path to a folder containing images is
      supported"""
  
      spec = full_precision_model.get_spec()
      num_inputs = len(spec.description.input)
      if isinstance(sample_data, str):
          input_type = spec.description.input[0].type.WhichOneof("Type")
          if num_inputs != 1 or input_type != "imageType":
              raise Exception(
                  """Unable to analyze quantized models. Sample data
              was a path to a directory which is only supported with models with
              one image type input. Please try passing in a list of sample inputs
              as sample data.
              """
              )
          _characterize_qmodel_perf_with_data_dir(
              full_precision_model,
              quantized_model.get_spec(),
              sample_data,
          )
  
      elif isinstance(sample_data, list):
          if not all(type(d) is dict for d in sample_data):
              raise Exception(emessage)
          _characterize_quantized_model_perf(
              full_precision_model,
              quantized_model.get_spec(),
              sample_data,
          )
  
      else:
          raise Exception(emessage)
  
imports: from os import listdir
  from sys import stdout
  import numpy
  from coremltools import ComputeUnit, _logger
  from coremltools._deps import _HAS_KMEANS1D, _kmeans1d
  from coremltools.models import _QUANTIZATION_MODE_CUSTOM_LOOKUP_TABLE, _QUANTIZATION_MODE_DEQUANTIZE, _QUANTIZATION_MODE_LINEAR_QUANTIZATION, _QUANTIZATION_MODE_LINEAR_SYMMETRIC, _QUANTIZATION_MODE_LOOKUP_TABLE_KMEANS, _QUANTIZATION_MODE_LOOKUP_TABLE_LINEAR, _SUPPORTED_QUANTIZATION_MODES, MLModel
  from ...None import _MINIMUM_FP16_SPEC_VERSION, _MINIMUM_QUANTIZED_MODEL_SPEC_VERSION, _SPECIFICATION_VERSION_IOS_14
  from ..utils import _get_model, _macos_version, _wp_to_fp16wp
  from .optimization_utils import _optimize_nn
label_desc: Use image node_id 19 for calling a global function with example usage: compare_models(full_precision_model, quantized_model, sample_data) without return types