class_docstr: Experimental class that wraps keepsake.init() and
  experiment.checkpoint() in a PyTorch Lightning callback.
  API is mostly consistent with keras_callback.KeepsakeCallback.
  
  This integration is subject to change, we'll probably
  try to get it into Pytorch Lightning itself as a logger.
  See https://github.com/replicate/keepsake/issues/432
  
  The KeepsakeCallback instantiates a new Keepsake experiment with
  keepsake.init on_pretrain_routine_start, using the parameters
  that are passed to the KeepsakeCallback constructor.
  
  Checkpoints are saved on_validation_end if validation is defined,
  otherwise on_epoch_end.
  
  For an example of how to use this callback, see the guide at
  https://keepsake.ai/docs/guides/pytorch-lightning-integration
code: def _save_model(self, trainer, pl_module):
      epoch = trainer.current_epoch
      global_step = trainer.global_step
  
      if (
          # no models are saved
          self.period < 1
          # skip epoch
          or (epoch + 1) % self.period
          # don't save anything during sanity check
          or trainer.running_sanity_check
          # already saved at the last step
          or self.last_global_step_saved == global_step
      ):
          return
  
      if self.filepath != None:
          trainer.save_checkpoint(self.filepath, self.save_weights_only)
  
      self.last_global_step_saved = global_step
  
      metrics = deepcopy(trainer.logger_connector.logged_metrics)
      metrics.update(trainer.logger_connector.callback_metrics)
      metrics.update(trainer.logger_connector.progress_bar_metrics)
      metrics.update({"global_step": trainer.global_step})
  
      self.experiment.checkpoint(
          path=self.filepath,
          step=trainer.current_epoch,
          metrics=metrics,
          primary_metric=self.primary_metric,
      )
  
file_path: keepsake/python/keepsake/pl_callback.py
imports: from copy import deepcopy
  from typing import Optional, Dict, Tuple, Any
  import keepsake
  from pytorch_lightning.callbacks.base import Callback
label_desc: Use image node_id 5 for calling the KeepsakeCallback obj's underlying member method code with example usage: obj._save_model(trainer, pl_module) without return types