code: def load_checkpoint(
      checkpoint_path: str, device: torch.device = CPU_DEVICE
  ) -> Optional[Dict]:
      """Loads a checkpoint from the specified checkpoint path.
  
      Args:
          checkpoint_path: The path to load the checkpoint from. Can be a file or a
              directory. If it is a directory, the checkpoint is loaded from
              :py:data:`CHECKPOINT_FILE` inside the directory.
          device: device to load the checkpoint to
  
      Returns:
          The checkpoint, if it exists, or None.
      """
      if not checkpoint_path:
          return None
  
      assert (
          device is not None
      ), "Please specify what device to load checkpoint on"
      assert device.type in ["cpu", "cuda"], f"Unknown device: {device}"
      if device.type == "cuda":
          assert torch.cuda.is_available()
  
      if not PathManager.exists(checkpoint_path):
          logging.warning(
              f"Checkpoint path {checkpoint_path} not found"
          )
          return None
      if PathManager.isdir(checkpoint_path):
          checkpoint_path = (
              f"{checkpoint_path.rstrip('/')}/{CHECKPOINT_FILE}"
          )
  
      if not PathManager.exists(checkpoint_path):
          logging.warning(
              f"Checkpoint file {checkpoint_path} not found."
          )
          return None
  
      logging.info(
          f"Attempting to load checkpoint from {checkpoint_path}"
      )
      # load model on specified device and not on saved device for model and return
      # the checkpoint
      with PathManager.open(checkpoint_path, "rb") as f:
          checkpoint = torch.load(f, map_location=device)
      logging.info(f"Loaded checkpoint from {checkpoint_path}")
      return checkpoint
  
imports: import collections.abc
  import contextlib
  import json
  import logging
  import os
  import time
  from functools import partial
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  import torch.nn
  from classy_vision.generic.distributed_util import broadcast_object, is_primary
  from fvcore.common.file_io import PathManager
label_desc: Use image node_id 17 for calling a global function with example usage: load_checkpoint(checkpoint_path, device) and returns: checkpoint, None, None, None