code: def save_checkpoint(
      checkpoint_folder, state, checkpoint_file=CHECKPOINT_FILE
  ):
      """
      Saves a state variable to the specified checkpoint folder. Returns the filename
      of the checkpoint if successful. Raises an exception otherwise.
      """
  
      # make sure that we have a checkpoint folder:
      if not PathManager.isdir(checkpoint_folder):
          try:
              PathManager.mkdirs(checkpoint_folder)
          except BaseException:
              logging.warning(
                  "Could not create folder %s." % checkpoint_folder
              )
              raise
  
      # write checkpoint atomically:
      try:
          full_filename = f"{checkpoint_folder}/{checkpoint_file}"
          with PathManager.open(full_filename, "wb") as f:
              torch.save(state, f)
          return full_filename
      except BaseException:
          logging.warning(
              "Unable to write checkpoint to %s." % checkpoint_folder,
              exc_info=True,
          )
          raise
  
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 20 for calling a global function with example usage: save_checkpoint(checkpoint_folder, state, checkpoint_file) and returns: full_filename