def METHOD_NAME(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