docstr: :param mlmodel: coremltools.models.MLModel
  Test the following:
  - calling .predict on mlmodel works correctly
  - calling .save on mlmodel works correctly
docstr_tok: [":","param","mlmodel",":","coremltools.models.MLModel","Test","the","following",":","-","calling",".predict","on","mlmodel","works","correctly","-","calling",".save","on","mlmodel","works","correctly"]
code: def _test_mlmodel_correctness(self, mlmodel):
      """
      :param mlmodel: coremltools.models.MLModel
      Test the following:
      - calling .predict on mlmodel works correctly
      - calling .save on mlmodel works correctly
      """
      # construct input dictionary
      spec = mlmodel.get_spec()
      inputs = spec.description.input
      input_dict = {}
      for input in inputs:
          input_dict[input.name] = np.random.rand(
              *tuple(input.type.multiArrayType.shape)
          )
      # check prediction
      preds = mlmodel.predict(input_dict)
      assert preds is not None
      # save, load and predict again to check that the saving and loading worked correctly
      with tempfile.TemporaryDirectory(
          suffix=utils._MLPACKAGE_EXTENSION
      ) as temp_path:
          mlmodel.save(temp_path)
          mlmodel_reloaded = MLModel(temp_path)
          preds = mlmodel_reloaded.predict(input_dict)
          assert preds is not None
  
imports: import os
  import shutil
  import tempfile
  import numpy
  import pytest
  import coremltools
  from coremltools import ComputeUnit, utils
  from coremltools._deps import _HAS_TORCH
  from coremltools.converters.mil import Builder
  from coremltools.libmodelpackage import ModelPackage
  from coremltools.models import MLModel
  from coremltools.models.utils import _MLPACKAGE_AUTHOR_NAME, _WEIGHTS_DIR_NAME
  from coremltools.proto import Model_pb2
label_desc: Use image node_id 3 for calling the TestSpecAndMLModelAPIs obj's underlying member method code with example usage: obj._test_mlmodel_correctness(mlmodel) without return types