class_docstr: Keras callback for Ray Train reporting and checkpointing.
  
  .. note::
      Metrics are always reported with checkpoints, even if the event isn't specified
      in ``report_metrics_on``.
  
  Example:
      .. code-block: python
  
          ############# Using it in TrainSession ###############
          from ray.air.integrations.keras import ReportCheckpointCallback
          def train_loop_per_worker():
              strategy = tf.distribute.MultiWorkerMirroredStrategy()
              with strategy.scope():
                  model = build_model()
  
              model.fit(dataset_shard, callbacks=[ReportCheckpointCallback()])
  
  Args:
      metrics: Metrics to report. If this is a list, each item describes
          the metric key reported to Keras, and it's reported under the
          same name. If this is a dict, each key is the name reported
          and the respective value is the metric key reported to Keras.
          If this is None, all Keras logs are reported.
      report_metrics_on: When to report metrics. Must be one of
          the Keras event hooks (less the ``on_``), e.g.
          "train_start" or "predict_end". Defaults to "epoch_end".
      checkpoint_on: When to save checkpoints. 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):
      assert (
          when in self._checkpoint_on or when in self._report_metrics_on
      )
  
      metrics = self._get_reported_metrics(logs)
  
      should_checkpoint = when in self._checkpoint_on
      if should_checkpoint:
          checkpoint = TensorflowCheckpoint.from_model(self.model)
          ray.train.report(metrics, checkpoint=checkpoint)
          # Clean up temporary checkpoint
          shutil.rmtree(checkpoint.path, ignore_errors=True)
      else:
          ray.train.report(metrics, checkpoint=None)
  
imports: import shutil
  from typing import Dict, List, Optional, Union
  from tensorflow.keras.callbacks import Callback
  import ray
  from ray.train.tensorflow import TensorflowCheckpoint
  from ray.util.annotations import PublicAPI
label_desc: Use image node_id 2 for calling the ReportCheckpointCallback obj's underlying member method code with example usage: obj._handle(logs, when) without return types