docstr: List up files in `dir_path` with `name_key`, then yield maximum suffix number.
  
  Args:
      dir_path: path of directory which may contain files whose name include `name_key`
      name_key: file name prefix
  Returns:
      None if no-corresponding-file else maximum suffix number
docstr_tok: ["List","up","files","in","`","dir_path","`","with","`","name_key","`",",","then","yield","maximum","suffix","number",".","Args",":","dir_path",":","path","of","directory","which","may","contain","files","whose","name","include","`","name_key","`","name_key",":","file","name","prefix","Returns",":","None","if","no-corresponding-file","else","maximum","suffix","number"]
code: def __max_ckpt_version_in_folder(
      dir_path: _PATH, name_key: str = "ckpt_"
  ) -> Optional[int]:
      """List up files in `dir_path` with `name_key`, then yield maximum suffix number.
  
      Args:
          dir_path: path of directory which may contain files whose name include `name_key`
          name_key: file name prefix
      Returns:
          None if no-corresponding-file else maximum suffix number
  
      """
      # check directory existence
      fs, uri = url_to_fs(str(dir_path))
      if not fs.exists(dir_path):
          return None
  
      # check corresponding file existence
      files = [os.path.basename(f["name"]) for f in fs.listdir(uri)]
      files = [x for x in files if name_key in x]
      if len(files) == 0:
          return None
  
      # extract suffix number
      ckpt_vs = []
      for name in files:
          name = name.split(name_key)[-1]
          name = re.sub("[^0-9]", "", name)
          ckpt_vs.append(int(name))
  
      return max(ckpt_vs)
  
imports: import logging
  import os
  import re
  from typing import Any, Dict, Optional
  import torch
  from fsspec.core import url_to_fs
  from fsspec.implementations.local import LocalFileSystem
  from torch import Tensor
  import lightning.pytorch
  from lightning.fabric.plugins.environments.slurm import SLURMEnvironment
  from lightning.fabric.utilities.cloud_io import _is_dir, get_filesystem
  from lightning.fabric.utilities.types import _PATH
  from lightning.pytorch.callbacks import ModelCheckpoint
  from lightning.pytorch.plugins.precision import MixedPrecision
  from lightning.pytorch.trainer import call
  from lightning.pytorch.trainer.states import TrainerFn
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from lightning.pytorch.utilities.imports import _OMEGACONF_AVAILABLE
  from lightning.pytorch.utilities.migration import pl_legacy_patch
  from lightning.pytorch.utilities.migration.utils import _pl_migrate_checkpoint
  from lightning.pytorch.utilities.rank_zero import rank_zero_info, rank_zero_warn
label_desc: Use image node_id 21 for calling the _CheckpointConnector obj's underlying member method code with example usage: obj.__max_ckpt_version_in_folder(dir_path, name_key) and returns: max, None, None