class_docstr: XGBoost callback to save checkpoints and report metrics.
  
  Saves checkpoints after each validation step. Also reports metrics to Ray Train
  or Ray Tune.
  
  Args:
      metrics: Metrics to report to Tune. If this is a list,
          each item describes the metric key reported to XGBoost,
          and it will be reported under the same name to Tune. If this is a
          dict, each key will be the name reported to Tune and the respective
          value will be the metric key reported to XGBoost.
      filename: Filename of the checkpoint within the checkpoint
          directory. Defaults to "checkpoint". If this is None,
          all metrics will be reported to Tune under their default names as
          obtained from XGBoost.
      frequency: How often to save checkpoints. Defaults to 0 (no checkpoints
          are saved during training). A checkpoint is always saved at the end
          of training.
      results_postprocessing_fn: An optional Callable that takes in
          the dict that will be reported to Tune (after it has been flattened)
          and returns a modified dict that will be reported instead. Can be used
          to eg. average results across CV fold when using ``xgboost.cv``.
  
  Example:
  
  .. code-block:: python
  
      import xgboost
      from ray.tune.integration.xgboost import TuneReportCheckpointCallback
  
      config = {
          # ...
          "eval_metric": ["auc", "logloss"]
      }
  
      # Report only log loss to Tune after each validation epoch.
      # Save model as `xgboost.mdl`.
      bst = xgb.train(
          config,
          train_set,
          evals=[(test_set, "eval")],
          verbose_eval=False,
          callbacks=[TuneReportCheckpointCallback(
              {"loss": "eval-logloss"}, "xgboost.mdl)])
code: def __init__(
      self,
      metrics: Optional[Union[str, List[str], Dict[str, str]]] = None,
      filename: str = "checkpoint",
      frequency: int = 1,
      results_postprocessing_fn: Optional[
          Callable[
              [Dict[str, Union[float, List[float]]]], Dict[str, float]
          ]
      ] = None,
  ):
      if isinstance(metrics, str):
          metrics = [metrics]
      self._metrics = metrics
      self._filename = filename
      self._frequency = frequency
      self._results_postprocessing_fn = results_postprocessing_fn
  
imports: from collections import OrderedDict
  from contextlib import contextmanager
  from typing import Callable, Dict, List, Union, Optional
  import os
  import tempfile
  import warnings
  from ray import train, tune
  from ray.train import Checkpoint
  from ray.tune.utils import flatten_dict
  from ray.util import log_once
  from ray.util.annotations import Deprecated
  from xgboost.core import Booster
label_desc: Use image node_id 1 to create a new TuneReportCheckpointCallback object from inherited base classes: TuneCallback with example: obj = TuneReportCheckpointCallback(metrics, filename, frequency, results_postprocessing_fn)