code: def _test_coreml_export(
      self,
      model,
      test_sf,
      is_regression,
      has_probability=None,
      predict_topk=None,
  ):
      if has_probability is None:
          has_probability = not is_regression
  
      if predict_topk is None:
          predict_topk = not is_regression
  
      # Act & Assert
      with tempfile.NamedTemporaryFile(
          mode="w", suffix=".mlmodel"
      ) as mlmodel_file:
          mlmodel_filename = mlmodel_file.name
          model.export_coreml(mlmodel_filename)
          import coremltools
  
          coreml_model = coremltools.models.MLModel(mlmodel_filename)
          metadata = coreml_model.user_defined_metadata
  
          self.assertEqual(
              metadata["com.github.apple.turicreate.version"],
              tc.__version__,
          )
          self.assertEqual(
              metadata["com.github.apple.os.platform"],
              platform.platform(),
          )
          self.assertEqual(metadata["type"], model.__class__.__name__)
  
          if _mac_ver() < (10, 13):
              print(
                  "Skipping export test; model not supported on this platform."
              )
              return
  
          def array_to_numpy(row):
              import array
              import numpy
              import copy
  
              row = copy.copy(row)
              for r in row:
                  if type(row[r]) == array.array:
                      row[r] = numpy.array(row[r])
              return row
  
          for row in test_sf:
              coreml_prediction = coreml_model.predict(
                  array_to_numpy(row)
              )
              tc_prediction = model.predict(row)[0]
  
              if (is_regression == False) and (
                  type(model.classes[0]) == str
              ):
                  if not has_probability:
                      self.assertEqual(
                          coreml_prediction["target"], tc_prediction
                      )
              else:
                  self.assertAlmostEqual(
                      coreml_prediction["target"],
                      tc_prediction,
                      delta=1e-5,
                  )
  
              # If applicable, compare probabilistic output
              if has_probability and not is_regression:
                  coreml_ret = coreml_prediction["targetProbability"]
                  _, values_tuple = zip(*sorted(coreml_ret.items()))
                  coreml_probs = np.array(values_tuple)
                  tc_probs = np.array(
                      model.predict(
                          row, output_type="probability_vector"
                      )[0]
                  )
                  np.testing.assert_array_almost_equal(
                      coreml_probs, tc_probs, decimal=5
                  )
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import unittest
  import tempfile
  import turicreate
  import math
  import uuid
  import random
  import copy
  from turicreate.toolkits import evaluation
  from turicreate.toolkits._main import ToolkitError
  from turicreate.toolkits._internal_utils import _mac_ver
  import shutil
  import numpy
  import sys
  import platform
  import array
  import os
  import pytest
label_desc: Use image node_id 2 for calling the CoreMLExportTest obj's underlying member method code with example usage: obj._test_coreml_export(model, test_sf, is_regression, has_probability, predict_topk) and returns: row