code: def get_checkpoint_state(
      checkpoint_dir: str, all_checkpoints=False
  ) -> Union[CheckpointState, None]:
      """
      Scan checkpoint directory and find the list of checkpoint files.
      :param checkpoint_dir: directory where checkpoints are saved
      :param all_checkpoints: if True, scan the directory and return list of all checkpoints
          as well as the most recent one
      :return: a CheckpointState for checkpoint_dir containing a sorted list of checkpoints by checkpoint-number.
          If no matching files are found, returns None.
      """
      return CheckpointStateUpdater(
          checkpoint_dir, read_all=all_checkpoints
      ).get_checkpoint_state()
  
imports: import os
  import re
  from typing import List, Union, Tuple
label_desc: Use image node_id 2 for calling a global function with example usage: get_checkpoint_state(checkpoint_dir, all_checkpoints) and returns: CheckpointStateUpdater