code: def evaluate_transformer(
      model, input_data, reference_output, verbose=False
  ):
      """
      Evaluate a transformer specification for testing.
  
      Parameters
      ----------
      spec: list of str or list of MLModel
          File from where to load the Model from (OR) a loaded
          version of MLModel.
  
      input_data: list of dict
          Test data on which to evaluate the models.
  
      reference_output: list of dict
          Expected results for the model.
  
      verbose: bool
          Verbosity levels of the predictions.
  
      Examples
      --------
      .. sourcecode:: python
  
          input_data = [{"input_1": 1, "input_2": 2}, {"input_1": 3, "input_2": 3}]
          expected_output = [{"input_1": 2.5, "input_2": 2.0}, {"input_1": 1.3, "input_2": 2.3}]
          metrics = coremltools.utils.evaluate_transformer(
              scaler_spec, input_data, expected_output
          )
  
      See Also
      --------
      evaluate_regressor, evaluate_classifier
      """
      model = _get_model(model)
      if verbose:
          print(model)
          print("")
          print("Other Framework\t\tPredicted")
  
      num_errors = 0
      for index, row in enumerate(input_data):
          assert isinstance(row, dict)
          sanitized_row = _sanitize_value(row)
          ref_data = _sanitize_value(reference_output[index])
          if verbose:
              print("Input:\n\t", str(row))
              print("Correct output:\n\t", str(ref_data))
  
          predicted = _sanitize_value(model.predict(sanitized_row))
  
          assert isinstance(ref_data, dict)
          assert isinstance(predicted, dict)
  
          predicted_trimmed = dict(
              (k, predicted[k]) for k in ref_data.keys()
          )
  
          if verbose:
              print("Predicted:\n\t", str(predicted_trimmed))
  
          if not _element_equal(predicted_trimmed, ref_data):
              num_errors += 1
  
      ret = {"num_samples": len(input_data), "num_errors": num_errors}
  
      if verbose:
          print("results: {}".format(ret))
      return ret
  
imports: from collections.abc import Iterable
  from functools import lru_cache
  import math
  import os
  import shutil
  import subprocess
  import sys
  import tempfile
  from typing import Optional, Union
  import warnings
  import numpy
  import coremltools
  from coremltools import ComputeUnit
  from coremltools.converters.mil.mil.passes.defs.preprocess import NameSanitizer
  from coremltools.proto import Model_pb2
  import coremltools.proto.MIL_pb2
  from .._deps import _HAS_SCIPY
label_desc: Use image node_id 19 for calling a global function with example usage: evaluate_transformer(model, input_data, reference_output, verbose) and returns: ret