code: def load_spec(model_path: str) -> _Model_pb2:
      """
      Load a protobuf model specification from file (mlmodel) or directory (mlpackage).
  
      Parameters
      ----------
      model_path: Path to the model from which the protobuf spec is loaded.
  
      Returns
      -------
      model_spec: Model_pb
          Protobuf representation of the model
  
      Examples
      --------
      .. sourcecode:: python
  
          spec = coremltools.utils.load_spec("HousePricer.mlmodel")
          spec = coremltools.utils.load_spec("HousePricer.mlpackage")
  
      See Also
      --------
      save_spec
      """
      if _os.path.isdir(model_path):
          if _ModelPackage is None:
              raise Exception(
                  "Unable to load libmodelpackage. Cannot make save spec."
              )
          specfile = _ModelPackage(model_path).getRootModel().path()
      else:
          specfile = model_path
  
      spec = _Model_pb2.Model()
      with open(specfile, "rb") as f:
          spec.ParseFromString(f.read())
      return spec
  
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 5 for calling a global function with example usage: load_spec(model_path) and returns: spec