class_docstr: Base container for ONNX models.
  The container allows to mirror the Sklearn API.
class_docstr_tok: ["Base","container","for","ONNX","models",".","The","container","allows","to","mirror","the","Sklearn","API","."]
docstr: Method used to load a container from the file system.
  
  Args:
      location: The location on the file system where to load the model.
      do_unzip_and_model_type_check: Whether to unzip the model and check the type.
  
  Returns:
      The loaded model.
docstr_tok: ["Method","used","to","load","a","container","from","the","file","system",".","Args",":","location",":","The","location","on","the","file","system","where","to","load","the","model",".","do_unzip_and_model_type_check",":","Whether","to","unzip","the","model","and","check","the","type",".","Returns",":","The","loaded","model","."]
code: def load(location, do_unzip_and_model_type_check=True, digest=None):
      """
      Method used to load a container from the file system.
  
      Args:
          location: The location on the file system where to load the model.
          do_unzip_and_model_type_check: Whether to unzip the model and check the type.
  
      Returns:
          The loaded model.
      """
  
      assert onnx_runtime_installed
      import onnx
      import onnxruntime as ort
      import hmac
      import hashlib
  
      container = None
  
      if do_unzip_and_model_type_check:
          # Unzip the dir.
          zip_location = location
          if not location.endswith("zip"):
              zip_location = location + ".zip"
          else:
              location = zip_location[:-4]
          assert os.path.exists(
              zip_location
          ), "Zip file {} does not exist.".format(zip_location)
  
          # Verify the digest if provided.
          if digest is None:
              print(
                  "Warning: No digest provided. Model integrity not verified."
              )
          else:
              with open(zip_location, "rb") as file:
                  new_digest = hmac.new(
                      b"shared-key", file.read(), hashlib.sha1
                  ).hexdigest()
                  if digest != new_digest:
                      raise RuntimeError("Integrity check failed")
  
          shutil.unpack_archive(zip_location, location, format="zip")
  
          assert os.path.exists(
              location
          ), "Model location {} does not exist.".format(location)
  
          # Load the model type.
          with open(
              os.path.join(
                  location, constants.SAVE_LOAD_MODEL_TYPE_PATH
              ),
              "r",
          ) as file:
              model_type = file.readline()
          if model_type != "onnx":
              shutil.rmtree(location)
              raise RuntimeError(
                  "Expected ONNX model type, got {}".format(model_type)
              )
  
      # Check the versions of the modules used when saving the model.
      if os.path.exists(
          os.path.join(
              location, constants.SAVE_LOAD_MODEL_CONFIGURATION_PATH
          )
      ):
          with open(
              os.path.join(
                  location, constants.SAVE_LOAD_MODEL_CONFIGURATION_PATH
              ),
              "r",
          ) as file:
              configuration = file.readlines()
          check_dumped_versions(configuration, hummingbird, torch, onnx)
      else:
          warnings.warn(
              "Cannot find the configuration file with versions. You are likely trying to load a model saved with an old version of Hummingbird."
          )
  
      # Load the actual model.
      model = onnx.load(
          os.path.join(location, constants.SAVE_LOAD_ONNX_PATH)
      )
  
      # Load the container.
      with open(
          os.path.join(location, constants.SAVE_LOAD_CONTAINER_PATH),
          "rb",
      ) as file:
          container = pickle.load(file)
      if container is None:
          shutil.rmtree(location)
          raise RuntimeError("Failed to load the model container.")
  
      # Setup the container.
      container._model = model
      sess_options = ort.SessionOptions()
      if container._n_threads is not None:
          # Need to set the number of threads to use as set in the original container.
          sess_options.intra_op_num_threads = container._n_threads
          sess_options.inter_op_num_threads = 1
          sess_options.execution_mode = ort.ExecutionMode.ORT_SEQUENTIAL
      container._session = ort.InferenceSession(
          container._model.SerializeToString(),
          sess_options=sess_options,
      )
  
      shutil.rmtree(location)
      return container
  
imports: import pickle
  import os
  import numpy
  import shutil
  import torch
  import warnings
  import hummingbird
  from hummingbird.ml._utils import onnx_runtime_installed, from_strings_to_ints, dump_versions, check_dumped_versions
  from hummingbird.ml.operator_converters import constants
  from hummingbird.ml.containers._sklearn_api_containers import SklearnContainer, SklearnContainerTransformer, SklearnContainerRegression, SklearnContainerClassification, SklearnContainerAnomalyDetection
  import onnx
label_desc: Use image node_id 3 for calling the ONNXSklearnContainer obj's underlying member method code with example usage: obj.load(location, do_unzip_and_model_type_check, digest) and returns: container