code: def check_sharded_checkpoint(
      checkpoint_path: Path, rank0_checkpoint_path: Path
  ) -> None:
      """Check sharded checkpoint state, ensuring the checkpoints are not corrupted."""
      # Finish the work of a previous run that got interrupted while dumping.
      old_path = Path(str(checkpoint_path) + ".old")
      if old_path.exists():
          raise RuntimeError(
              f"Old checkpoint {old_path} from previous version of this code exist, cannot safely proceed."
          )
      token = Path(str(rank0_checkpoint_path) + ".tmp.done")
      tmp_path = Path(str(checkpoint_path) + ".tmp")
      if token.exists():
          if tmp_path.exists():
              tmp_path.rename(checkpoint_path)
      flashy.distrib.barrier()
      if flashy.distrib.is_rank_zero() and token.exists():
          token.unlink()
  
file_path: audiocraft/audiocraft/utils/checkpoint.py
imports: from enum import Enum
  import logging
  from pathlib import Path
  import re
  import typing
  import flashy
  import torch
  from ..environment import AudioCraftEnvironment
label_desc: Use image node_id 7 for calling a global function with example usage: check_sharded_checkpoint(checkpoint_path, rank0_checkpoint_path) without return types