class_docstr: CheckpointSaver acts as an Ignite handler to save checkpoint data into files.
  It supports to save according to metrics result, epoch number, iteration number
  and last model or exception.
  
  Args:
      save_dir: the target directory to save the checkpoints.
      save_dict: source objects that save to the checkpoint. examples::
  
          {'network': net, 'optimizer': optimizer, 'lr_scheduler': lr_scheduler}
  
      name: identifier of logging.logger to use, if None, defaulting to ``engine.logger``.
      file_prefix: prefix for the filenames to which objects will be saved.
      save_final: whether to save checkpoint or session at final iteration or exception.
          If checkpoints are to be saved when an exception is raised, put this handler before
          `StatsHandler` in the handler list, because the logic with Ignite can only trigger
          the first attached handler for `EXCEPTION_RAISED` event.
      final_filename: set a fixed filename to save the final model if `save_final=True`.
          If None, default to `checkpoint_final_iteration=N.pt`.
      save_key_metric: whether to save checkpoint or session when the value of key_metric is
          higher than all the previous values during training.keep 4 decimal places of metric,
          checkpoint name is: {file_prefix}_key_metric=0.XXXX.pth.
      key_metric_name: the name of key_metric in ignite metrics dictionary.
          If None, use `engine.state.key_metric` instead.
      key_metric_n_saved: save top N checkpoints or sessions, sorted by the value of key
          metric in descending order.
      key_metric_filename: set a fixed filename to set the best metric model, if not None,
          `key_metric_n_saved` should be 1 and only keep the best metric model.
      key_metric_save_state: whether to save the tracking list of key metric in the checkpoint file.
          if `True`, then will save an object in the checkpoint file with key `checkpointer` to be
          consistent with the `include_self` arg of `Checkpoint` in ignite:
          https://pytorch.org/ignite/v0.4.5/generated/ignite.handlers.checkpoint.Checkpoint.html.
          typically, it's used to resume training and compare current metric with previous N values.
      key_metric_greater_or_equal: if `True`, the latest equally scored model is stored. Otherwise,
          save the first equally scored model. default to `False`.
      key_metric_negative_sign: whether adding a negative sign to the metric score to compare metrics,
          because for error-like metrics, smaller is better(objects with larger score are retained).
          default to `False`.
      epoch_level: save checkpoint during training for every N epochs or every N iterations.
          `True` is epoch level, `False` is iteration level.
      save_interval: save checkpoint every N epochs, default is 0 to save no checkpoint.
      n_saved: save latest N checkpoints of epoch level or iteration level, 'None' is to save all.
  
  Note:
      CheckpointHandler can be used during training, validation or evaluation.
      example of saved files:
  
          - checkpoint_iteration=400.pt
          - checkpoint_iteration=800.pt
          - checkpoint_epoch=1.pt
          - checkpoint_final_iteration=1000.pt
          - checkpoint_key_metric=0.9387.pt
class_docstr_tok: ["CheckpointSaver","acts","as","an","Ignite","handler","to","save","checkpoint","data","into","files",".","It","supports","to","save","according","to","metrics","result",",","epoch","number",",","iteration","number","and","last","model","or","exception",".","Args",":","save_dir",":","the","target","directory","to","save","the","checkpoints",".","save_dict",":","source","objects","that","save","to","the","checkpoint",".","examples",":",":","{","'network","'",":","net",",","'optimizer","'",":","optimizer",",","'lr_scheduler","'",":","lr_scheduler","}","name",":","identifier","of","logging.logger","to","use",",","if","None",",","defaulting","to","``","engine.logger","``",".","file_prefix",":","prefix","for","the","filenames","to","which","objects","will","be","saved",".","save_final",":","whether","to","save","checkpoint","or","session","at","final","iteration","or","exception",".","If","checkpoints","are","to","be","saved","when","an","exception","is","raised",",","put","this","handler","before","`","StatsHandler","`","in","the","handler","list",",","because","the","logic","with","Ignite","can","only","trigger","the","first","attached","handler","for","`","EXCEPTION_RAISED","`","event",".","final_filename",":","set","a","fixed","filename","to","save","the","final","model","if","`","save_final=True","`",".","If","None",",","default","to","`","checkpoint_final_iteration=N.pt","`",".","save_key_metric",":","whether","to","save","checkpoint","or","session","when","the","value","of","key_metric","is","higher","than","all","the","previous","values","during","training.keep","4","decimal","places","of","metric",",","checkpoint","name","is",":","{","file_prefix","}","_key_metric=0.XXXX.pth",".","key_metric_name",":","the","name","of","key_metric","in","ignite","metrics","dictionary",".","If","None",",","use","`","engine.state.key_metric","`","instead",".","key_metric_n_saved",":","save","top","N","checkpoints","or","sessions",",","sorted","by","the","value","of","key","metric","in","descending","order",".","key_metric_filename",":","set","a","fixed","filename","to","set","the","best","metric","model",",","if","not","None",",","`","key_metric_n_saved","`","should","be","1","and","only","keep","the","best","metric","model",".","key_metric_save_state",":","whether","to","save","the","tracking","list","of","key","metric","in","the","checkpoint","file",".","if","`","True","`",",","then","will","save","an","object","in","the","checkpoint","file","with","key","`","checkpointer","`","to","be","consistent","with","the","`","include_self","`","arg","of","`","Checkpoint","`","in","ignite",":","https",":","\/\/pytorch.org\/ignite\/v0.4.5\/generated\/ignite.handlers.checkpoint.Checkpoint.html",".","typically",",","it","'s","used","to","resume","training","and","compare","current","metric","with","previous","N","values",".","key_metric_greater_or_equal",":","if","`","True","`",",","the","latest","equally","scored","model","is","stored",".","Otherwise",",","save","the","first","equally","scored","model",".","default","to","`","False","`",".","key_metric_negative_sign",":","whether","adding","a","negative","sign","to","the","metric","score","to","compare","metrics",",","because","for","error-like","metrics",",","smaller","is","better","(","objects","with","larger","score","are","retained",")",".","default","to","`","False","`",".","epoch_level",":","save","checkpoint","during","training","for","every","N","epochs","or","every","N","iterations",".","`","True","`","is","epoch","level",",","`","False","`","is","iteration","level",".","save_interval",":","save","checkpoint","every","N","epochs",",","default","is","0","to","save","no","checkpoint",".","n_saved",":","save","latest","N","checkpoints","of","epoch","level","or","iteration","level",",","'None","'","is","to","save","all",".","Note",":","CheckpointHandler","can","be","used","during","training",",","validation","or","evaluation",".","example","of","saved","files",":","-","checkpoint_iteration=400.pt","-","checkpoint_iteration=800.pt","-","checkpoint_epoch=1.pt","-","checkpoint_final_iteration=1000.pt","-","checkpoint_key_metric=0.9387.pt"]
docstr: Callback for train or validation/evaluation completed Event.
  Save final checkpoint if configure save_final is True.
  
  Args:
      engine: Ignite Engine, it can be a trainer, validator or evaluator.
docstr_tok: ["Callback","for","train","or","validation\/evaluation","completed","Event",".","Save","final","checkpoint","if","configure","save_final","is","True",".","Args",":","engine",":","Ignite","Engine",",","it","can","be","a","trainer",",","validator","or","evaluator","."]
code: def completed(self, engine: Engine) -> None:
      """Callback for train or validation/evaluation completed Event.
      Save final checkpoint if configure save_final is True.
  
      Args:
          engine: Ignite Engine, it can be a trainer, validator or evaluator.
      """
      if not callable(self._final_checkpoint):
          raise AssertionError(
              "Error: _final_checkpoint function not specified."
          )
      # delete previous saved final checkpoint if existing
      self._delete_previous_final_ckpt()
      self._final_checkpoint(engine)
      if self.logger is None:
          raise AssertionError
      if not hasattr(self.logger, "info"):
          raise AssertionError(
              "Error, provided logger has not info attribute."
          )
      if self._final_filename is not None:
          _final_checkpoint_path = os.path.join(
              self.save_dir, self._final_filename
          )
      else:
          _final_checkpoint_path = self._final_checkpoint.last_checkpoint  # type: ignore[assignment]
      self.logger.info(
          f"Train completed, saved final checkpoint: {_final_checkpoint_path}"
      )
  
file_path: MONAI/monai/handlers/checkpoint_saver.py
imports: from __future__ import annotations
  import logging
  import os
  import warnings
  from collections.abc import Mapping
  from typing import TYPE_CHECKING, Any
  from monai.config import IgniteInfo
  from monai.utils import is_scalar, min_version, optional_import
label_desc: Use image node_id 5 for calling the CheckpointSaver obj's underlying member method code with example usage: obj.completed(engine) without return types