class_docstr: A custom early stopping class where early stopping is determined stochastically.
  In the beginning, allow the metric to become worse with a probability of 0.999.
  As boosting progresses, the probability should be adjusted downward
class_docstr_tok: ["A","custom","early","stopping","class","where","early","stopping","is","determined","stochastically",".","In","the","beginning",",","allow","the","metric","to","become","worse","with","a","probability","of","0.999",".","As","boosting","progresses",",","the","probability","should","be","adjusted","downward"]
code: def after_iteration(self, model, epoch, evals_log):
      metric_history = evals_log[self.validation_set][
          self.target_metric
      ]
      if len(metric_history) < 2 or self.better(
          metric_history[-1], metric_history[-2]
      ):
          return False  # continue training
      p = probability_for_going_backward(epoch)
      go_backward = self.rng.choice(
          2, size=(1,), replace=True, p=[1 - p, p]
      ).astype(np.bool)[0]
      print(
          "The validation metric went into the wrong direction. "
          + f"Stopping training with probability {1 - p}..."
      )
      if go_backward:
          return False  # continue training
      else:
          return True
  
file_path: xgboost/demo/dask/dask_callbacks.py
imports: import numpy
  from dask.distributed import Client, LocalCluster
  from dask_ml.datasets import make_regression
  from dask_ml.model_selection import train_test_split
  import xgboost
  import xgboost.dask
  from xgboost.dask import DaskDMatrix
label_desc: Use image node_id 2 for calling the CustomEarlyStopping obj's underlying member method code with example usage: obj.after_iteration(model, epoch, evals_log) and returns: False, False, True