code: def get_checkpoint_dirpaths(
      dirpath: str,
      metadata_fname: Optional[str] = None,
      process_group: Optional[dist.ProcessGroup] = None,
  ) -> List[str]:
      """
      Given a parent directory where checkpoints are saved, return the sorted checkpoint subdirectories
      from oldest to newest.
  
      Args:
          dirpath: parent directory where checkpoints are saved.
          metadata_fname: Checks if metadata file is present in checkpoint, disregards if it does not exist.
          process_group: the process group on which the ranks will communicate on. default: ``None`` (the entire world)
      """
  
      def sort_fn(path: str) -> Tuple[int, int]:
          x = os.path.basename(path)
          return (int(x.split("_")[1]), int(x.split("_")[3]))
  
      dirpaths = _retrieve_checkpoint_dirpaths(dirpath, metadata_fname)
      return sorted(dirpaths, key=sort_fn)
  
imports: import logging
  import os
  import re
  from typing import Any, Callable, cast, Dict, List, Optional, Pattern, Tuple, TypeVar
  import fsspec
  from pyre_extensions import none_throws
  from torch import distributed
  from torchtnt.framework.callbacks.checkpointer_types import RestoreOptions
  from torchtnt.framework.state import State
  from torchtnt.framework.unit import AppStateMixin
  from torchtnt.utils.distributed import get_global_rank, PGWrapper
  from torchtnt.utils.fsspec import get_filesystem
  from torchtnt.utils.stateful import Stateful
label_desc: Use image node_id 4 for calling a global function with example usage: get_checkpoint_dirpaths(dirpath, metadata_fname, process_group) and returns: sorted, int,  int