class_docstr: Keras checkpoint callback
  
  Saves checkpoints after each validation step.
  
  Checkpoint are currently not registered if no ``tune.report()`` call
  is made afterwards. Consider using ``TuneReportCheckpointCallback``
  instead.
  
  Args:
      filename: Filename of the checkpoint within the checkpoint
          directory. Defaults to "checkpoint".
      frequency: Checkpoint frequency. If this is an integer `n`,
          checkpoints are saved every `n` times each hook was called. If
          this is a list, it specifies the checkpoint frequencies for each
          hook individually.
      on: When to trigger checkpoint creations. Must be one of
          the Keras event hooks (less the ``on_``), e.g.
          "train_start", or "predict_end". Defaults to "epoch_end".
class_docstr_tok: ["Keras","checkpoint","callback","Saves","checkpoints","after","each","validation","step",".","Checkpoint","are","currently","not","registered","if","no","``","tune.report","(",")","``","call","is","made","afterwards",".","Consider","using","``","TuneReportCheckpointCallback","``","instead",".","Args",":","filename",":","Filename","of","the","checkpoint","within","the","checkpoint","directory",".","Defaults","to","``","checkpoint","''",".","frequency",":","Checkpoint","frequency",".","If","this","is","an","integer","`","n","`",",","checkpoints","are","saved","every","`","n","`","times","each","hook","was","called",".","If","this","is","a","list",",","it","specifies","the","checkpoint","frequencies","for","each","hook","individually",".","on",":","When","to","trigger","checkpoint","creations",".","Must","be","one","of","the","Keras","event","hooks","(","less","the","``","on_","``",")",",","e.g",".","``","train_start","''",",","or","``","predict_end","''",".","Defaults","to","``","epoch_end","''","."]
code: def _handle(self, logs: Dict, when: str = None):
      self._counter[when] += 1
  
      if isinstance(self._frequency, list):
          index = self._on.index(when)
          freq = self._frequency[index]
      else:
          freq = self._frequency
  
      if self._counter[when] % freq == 0:
          with tune.checkpoint_dir(
              step=self._cp_count
          ) as checkpoint_dir:
              self.model.save(
                  os.path.join(checkpoint_dir, self._filename),
                  overwrite=True,
              )
              self._cp_count += 1
  
file_path: ray/python/ray/tune/integration/keras.py
imports: import os
  from collections import Counter
  from typing import Dict, List, Optional, Union
  from ray import tune
  from ray.util.annotations import Deprecated
  from ray.air.integrations.keras import _Callback
label_desc: Use image node_id 2 for calling the _TuneCheckpointCallback obj's underlying member method code with example usage: obj._handle(logs, when) without return types