code: def custom_callback() -> None:
      """Demo for defining a custom callback function that plots evaluation result during
      training."""
      X, y = load_breast_cancer(return_X_y=True)
      X_train, X_valid, y_train, y_valid = train_test_split(
          X, y, random_state=0
      )
  
      D_train = xgb.DMatrix(X_train, y_train)
      D_valid = xgb.DMatrix(X_valid, y_valid)
  
      num_boost_round = 100
      plotting = Plotting(num_boost_round)
  
      # Pass it to the `callbacks` parameter as a list.
      xgb.train(
          {
              "objective": "binary:logistic",
              "eval_metric": ["error", "rmse"],
              "tree_method": "hist",
              "device": "cuda",
          },
          D_train,
          evals=[(D_train, "Train"), (D_valid, "Valid")],
          num_boost_round=num_boost_round,
          callbacks=[plotting],
      )
  
file_path: xgboost/demo/guide-python/callbacks.py
imports: import argparse
  import os
  import tempfile
  from typing import Dict
  import numpy
  from matplotlib import pyplot
  from sklearn.datasets import load_breast_cancer
  from sklearn.model_selection import train_test_split
  import xgboost
label_desc: Use image node_id 1 for calling a global function with example usage: custom_callback() without return types