code: def load_checkpoint(
      checkpoint_path,
      model=None,
      device="cpu",
      strict=True,
      ignore_chkpt_layers=None,
  ):
      """
      Loads weights from a checkpoint into memory. If model is not None then the weights are loaded into the model.
  
      :param checkpoint_path: (string):
          path to a pretrained network to load weights from
      :param model: the model object to load weights onto (default: None)
      :param device: (string):
          which device to load model onto (default:'cpu')
      :param strict: (bool):
          whether to ensure strict key matching (True) or to ignore non-matching keys. (default: True)
      :param ignore_chkpt_layers: one of {string, list) -- CURRENTLY UNIMPLEMENTED:
          whether to ignore some subset of layers from checkpoint. This is usually done when loading
          checkpoint data into a model with a different number of final classes. In that case, you can pass in a
          special string: 'last_layer' which will trigger the logic to chop off the last layer of the checkpoint dictionary. Otherwise
          you can pass in a list of layers to remove from the checkpoint before loading it (e.g. you would do that when
          loading an inception model that has more than one output layer).
  
      :return: checkpoint
      """
  
      # Handle incompatibility between pytorch0.4 and pytorch0.4.x
      # Source: https://discuss.pytorch.org/t/question-about-rebuild-tensor-v2/14560/2
  
      import torch._utils
  
      try:
          torch._utils._rebuild_tensor_v2
      except AttributeError:
  
          def _rebuild_tensor_v2(
              storage,
              storage_offset,
              size,
              stride,
              requires_grad,
              backward_hooks,
          ):
              tensor = torch._utils._rebuild_tensor(
                  storage, storage_offset, size, stride
              )
              tensor.requires_grad = requires_grad
              tensor._backward_hooks = backward_hooks
              return tensor
  
          torch._utils._rebuild_tensor_v2 = _rebuild_tensor_v2
  
      checkpoint = None
      if checkpoint_path:
          # load data directly from a checkpoint
          checkpoint_path = os.path.expanduser(checkpoint_path)
          if os.path.isfile(checkpoint_path):
              print(
                  "=> Loading checkpoint: {} onto device: {}".format(
                      checkpoint_path, device
                  )
              )
              checkpoint = torch.load(
                  checkpoint_path, map_location=device
              )
  
              pretrained_state = checkpoint["state_dict"]
              print(
                  "INFO: => loaded checkpoint {} (epoch {})".format(
                      checkpoint_path, checkpoint.get("epoch")
                  )
              )
              print(
                  "INFO: => checkpoint model name: ",
                  checkpoint.get(
                      "modelname", checkpoint.get("model_name")
                  ),
                  " Make sure the checkpoint model name matches your model!!!",
              )
          else:
              raise FileNotFoundError(
                  errno.ENOENT,
                  os.strerror(errno.ENOENT),
                  checkpoint_path,
              )
  
          # If the state_dict was saved from parallelized process the key names will start with 'module.'
          # If using ModelCheckpoint the model should already be correctly saved regardless of whether the model was parallelized or not
          is_parallel = False
          for key in pretrained_state:
              if key.startswith("module."):
                  is_parallel = True
                  break
  
          if (
              is_parallel
          ):  # do the work of re-assigning each key (must create a copy due to the use of OrderedDict)
              from collections import OrderedDict
  
              new_state_dict = OrderedDict()
              for k, v in pretrained_state.items():
                  if k.startswith("module."):
                      name = k[7:]  # remove `module.`
                      new_state_dict[name] = v
                  else:
                      new_state_dict[k] = v
              checkpoint["state_dict"] = new_state_dict
  
          # finally load the model weights
          if model:
              print(
                  "INFO: => Attempting to load checkpoint data onto model. Device: {}    Strict: {}".format(
                      device, strict
                  )
              )
              model.load_state_dict(
                  checkpoint["state_dict"], strict=strict
              )
      return checkpoint
  
imports: from functools import partial
  from typing import Callable
  from torchvision.models.resnet import Bottleneck
  from .None import classification
  from .segmentation import *
  from .None import segmentation
  from enum import Enum
  from torchvision import models
  from torchvision.models.inception import InceptionAux
  import torch
  import torch.nn
  import os
  import errno
label_desc: Use image node_id 6 for calling a global function with example usage: load_checkpoint(checkpoint_path, model, device, strict, ignore_chkpt_layers) and returns: checkpoint, tensor