class_docstr: Class that inherits callbacks.ModelCheckpoint. The purpose is to resolve the potential issues in lightning.
  
  - Issue1:
  
  It solves the issue described in https://github.com/Lightning-AI/lightning/issues/5582.
  For ddp_spawn, the checkpoint_callback.best_k_models will be empty.
  Here, we resolve it by storing the best_models to "SAVE_DIR/best_k_models.yaml".
code: def _save_checkpoint(self, trainer, filepath):
      # Deepspeed saves model and optimizer states in a shared state in a separate folder
      if isinstance(trainer.strategy, DeepSpeedStrategy):
          trainer.save_checkpoint(
              filepath + "-dir", self.save_weights_only
          )
      else:
          trainer.save_checkpoint(filepath, self.save_weights_only)
  
      # Required to avoid redundant evaluation and checkpointing
      self._last_global_step_saved = trainer.global_step
  
imports: import logging
  import os
  import re
  import shutil
  from typing import Any, Dict, List, Optional, Tuple, Union
  import lightning.pytorch
  import torch
  from lightning.pytorch.strategies import DeepSpeedStrategy
  from lightning.pytorch.utilities.rank_zero import rank_zero_warn
  from .cloud_io import _atomic_save
  from .cloud_io import _load
  from .cloud_io import get_filesystem
label_desc: Use image node_id 1 for calling the AutoMMModelCheckpoint obj's underlying member method code with example usage: obj._save_checkpoint(trainer, filepath) without return types