code: def compare_models(full_precision_model, quantized_model,
                                sample_data):
      
      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)
docs: Utility function to compare the performance of a full precision vs quantized model
  
      :param full_precision_model: MLModel
          The full precision model with float32 weights
  
      :param quantized_model: MLModel
          Quantized version of the model with quantized weights
  
      :param 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