class_docstr: Base container for PyTorch models.
class_docstr_tok: ["Base","container","for","PyTorch","models","."]
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.
      delete_unzip_location_folder: Whether to delete the folder provided by caller or created by this method
                                      where the model is unzipped
  
  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",".","delete_unzip_location_folder",":","Whether","to","delete","the","folder","provided","by","caller","or","created","by","this","method","where","the","model","is","unzipped","Returns",":","The","loaded","model","."]
code: def load(
      location,
      do_unzip_and_model_type_check=True,
      delete_unzip_location_folder: bool = 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.
          delete_unzip_location_folder: Whether to delete the folder provided by caller or created by this method
                                          where the model is unzipped
  
      Returns:
          The loaded model.
      """
      import hmac
      import hashlib
  
      container = None
  
      # Unzip the dir.
      if do_unzip_and_model_type_check:
          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()
  
      # 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)
      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."
          )
  
      if model_type == "torch.jit":
          # This is a torch.jit model
          model = torch.jit.load(
              os.path.join(location, constants.SAVE_LOAD_TORCH_JIT_PATH)
          )
          with open(
              os.path.join(location, "container.pkl"), "rb"
          ) as file:
              container = pickle.load(file)
          container._model = model
      elif model_type == "torch":
          # This is a pytorch  model
          with open(
              os.path.join(
                  location, constants.SAVE_LOAD_TORCH_JIT_PATH
              ),
              "rb",
          ) as file:
              container = pickle.load(file)
      else:
          if delete_unzip_location_folder:
              shutil.rmtree(location)
          raise RuntimeError(
              "Model type {} not recognized".format(model_type)
          )
  
      # Need to set the number of threads to use as set in the original container.
      if container._n_threads is not None:
          if torch.get_num_interop_threads() != 1:
              torch.set_num_interop_threads(1)
          torch.set_num_threads(container._n_threads)
  
      if delete_unzip_location_folder:
          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 pandas_installed, get_device, 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
label_desc: Use image node_id 2 for calling the PyTorchSklearnContainer obj's underlying member method code with example usage: obj.load(location, do_unzip_and_model_type_check, delete_unzip_location_folder, digest) and returns: container