code: def _generate_training_callback_class(cls):
      try:
          from xgboost.callback import TrainingCallback  # noqa
      except ImportError:
          return None
  
      class ClearMLCallback(TrainingCallback):
          """
          Log evaluation result at each iteration.
          """
  
          _scalar_index_counter = 0
  
          def __init__(self, task, period=1):
              self.period = period
              assert period > 0
              self._last_eval = None
              self._last_eval_epoch = None
              self._logger = task.get_logger()
              self._scalar_index = ClearMLCallback._scalar_index_counter
              ClearMLCallback._scalar_index_counter += 1
              super(ClearMLCallback, self).__init__()
  
          def after_iteration(self, model, epoch, evals_log):
              """Run after each iteration.  Return True when training should stop."""
              if not evals_log:
                  return False
  
              if not (self.period == 1 or (epoch % self.period) == 0):
                  self._last_eval = evals_log
                  self._last_eval_epoch = epoch
                  return False
  
              self._report_eval_log(epoch, evals_log)
  
              self._last_eval = None
              self._last_eval_epoch = None
              return False
  
          def after_training(self, model):
              """Run after training is finished."""
              if self._last_eval:
                  self._report_eval_log(
                      self._last_eval_epoch, self._last_eval
                  )
  
              return model
  
          def _report_eval_log(self, epoch, eval_log):
              for data, metric in eval_log.items():
                  if self._scalar_index != 0:
                      data = "{} - {}".format(data, self._scalar_index)
                  for metric_name, log in metric.items():
                      value = log[-1]
  
                      self._logger.report_scalar(
                          title=data,
                          series=metric_name,
                          value=value,
                          iteration=epoch,
                      )
  
      return ClearMLCallback
  
file_path: clearml/clearml/binding/frameworks/xgboost_bind.py
imports: import sys
  import six
  from pathlib2 import Path
  from ..frameworks.base_bind import PatchBaseModelIO
  from ..frameworks import _patched_call, WeightsFileHandler, _Empty
  from ..import_bind import PostImportHookPatching
  from ...config import running_remotely
  from ...model import Framework
label_desc: Use image node_id 6 for calling the PatchXGBoostModelIO obj's underlying member method code with example usage: obj._generate_training_callback_class(cls) and returns: ClearMLCallback, None, False, model, False, False