code: def _upgrade(args: Namespace) -> None:
      path = Path(args.path).absolute()
      extension: str = (
          args.extension
          if args.extension.startswith(".")
          else f".{args.extension}"
      )
      files: List[Path] = []
  
      if not path.exists():
          _log.error(
              f"The path {path} does not exist. Please provide a valid path to a checkpoint file or a directory"
              f" containing checkpoints ending in {extension}."
          )
          exit(1)
  
      if path.is_file():
          files = [path]
      if path.is_dir():
          files = [
              Path(p)
              for p in glob.glob(
                  str(path / "**" / f"*{extension}"), recursive=True
              )
          ]
      if not files:
          _log.error(
              f"No checkpoint files with extension {extension} were found in {path}."
              f" HINT: Try setting the `--extension` option to specify the right file extension to look for."
          )
          exit(1)
  
      _log.info(
          "Creating a backup of the existing checkpoint files before overwriting in the upgrade process."
      )
      for file in files:
          backup_file = file.with_suffix(".bak")
          if backup_file.exists():
              # never overwrite backup files - they are the original, untouched checkpoints
              continue
          copyfile(file, backup_file)
  
      _log.info("Upgrading checkpoints ...")
      for file in tqdm(files):
          with pl_legacy_patch():
              checkpoint = torch.load(
                  file,
                  map_location=(
                      torch.device("cpu") if args.map_to_cpu else None
                  ),
              )
          migrate_checkpoint(checkpoint)
          torch.save(checkpoint, file)
  
      _log.info("Done.")
  
file_path: pytorch-lightning/src/lightning/pytorch/utilities/upgrade_checkpoint.py
imports: import glob
  import logging
  from argparse import ArgumentParser, Namespace
  from pathlib import Path
  from shutil import copyfile
  from typing import List
  import torch
  from tqdm import tqdm
  from lightning.pytorch.utilities.migration import migrate_checkpoint, pl_legacy_patch
label_desc: Use image node_id 1 for calling a global function with example usage: _upgrade(args) without return types