code: def update_checkpoint(
      cfg: DictConfig,
      key: str,
      prefix: str = "model",
      suffix: str = "pt",
  ):
      """
      Udpdate the checkpoint in a configuration.
  
      Args:
          cfg: The configuration to update.
          key: The dot-notation key pointing to the checkpoint
              in the configuration.
          prefix: File extension of the checkpoint file.
          suffix: Suffix of the checkpoint file.
      """
      ckpt_path = OmegaConf.select(cfg, key)
  
      if ckpt_path:
          ckpt_path = Path(to_absolute_path(ckpt_path))
      else:
          assert logger.get_dir() is not None
          ckpt_path = Path.cwd() / logger.get_dir()
  
      if ckpt_path.is_dir():
          # search for the last checkpoint
          ckpt_files = list(ckpt_path.glob(f"{prefix}*.{suffix}"))
          if ckpt_files:
              ckpt_path = max(
                  ckpt_files, key=parse_resume_step_from_filename
              )
  
      if ckpt_path.is_file():
          OmegaConf.update(cfg, key, str(ckpt_path))
  
imports: import copy
  import hashlib
  from pathlib import Path
  from typing import List, Set, Union
  import numpy
  import plotly.graph_objs
  import torch
  import torch.distributed
  import wandb
  from hydra.core.hydra_config import HydraConfig
  from hydra.utils import instantiate, to_absolute_path
  from improved_diffusion import dist_util
  from improved_diffusion import gaussian_diffusion
  from improved_diffusion import logger, respace, train_util
  from omegaconf import DictConfig, OmegaConf
label_desc: Use image node_id 3 for calling a global function with example usage: update_checkpoint(cfg, key, prefix, suffix) without return types