code: def get_latest_checkpoint_path(dir_path: Optional[str] = None) -> str:
      """
      Get the latest checkpoint path
      args:
          dir_path: the dir to scan for existing checkpoint files. Default: if None,
          the latest checkpoint path saved in momery will be returned
      Returns: checkpoint_path
      """
      if not dir_path:
          return _CHECKPOINT_MANAGER.get_latest_checkpoint_path()
  
      if PathManager.exists(dir_path):
          checkpoint_indices = [
              int(file_path.split("-")[1])
              for file_path in PathManager.ls(dir_path)
              if file_path.startswith("checkpoint")
          ]
          if checkpoint_indices:
              latest_checkpoint_path = (
                  f"{dir_path}/checkpoint-{max(checkpoint_indices)}"
              )
              logger.info(
                  f"find the latest checkpoint: {latest_checkpoint_path}"
              )
              return latest_checkpoint_path
      return None
  
imports: import io
  import logging
  import os
  from typing import Dict, Optional
  import torch
  from pytext.config import config_to_json, pytext_config_from_json, PyTextConfig
  from pytext.data import CommonMetadata
  from pytext.data.tensorizers import Tensorizer
  from pytext.models import Model
  from pytext.trainers.training_state import TrainingState
  from pytext.utils.file_io import PathManager
  from .pytext_checkpoint_management import get_checkpoint_manager
label_desc: Use image node_id 7 for calling a global function with example usage: get_latest_checkpoint_path(dir_path) and returns: None, _CHECKPOINT_MANAGER, latest_checkpoint_path