code: def train_breast_cancer(config: dict):
      # This is a simple training function to be passed into Tune
      # Load dataset
      data, labels = sklearn.datasets.load_breast_cancer(
          return_X_y=True
      )
      # Split into train and test set
      train_x, test_x, train_y, test_y = train_test_split(
          data, labels, test_size=0.25
      )
      # Build input matrices for XGBoost
      train_set = xgb.DMatrix(train_x, label=train_y)
      test_set = xgb.DMatrix(test_x, label=test_y)
  
      # Checkpointing needs to be set up in order for dynamic
      # resource allocation to work as intended
      xgb_model = None
      checkpoint = train.get_checkpoint()
      if checkpoint:
          xgb_model = xgb.Booster()
          with checkpoint.as_directory() as checkpoint_dir:
              xgb_model.load_model(
                  os.path.join(checkpoint_dir, CHECKPOINT_FILENAME)
              )
  
      # we can obtain current trial resources through
      # `tune.get_trial_resources()`
      config["nthread"] = int(
          train.get_context().get_trial_resources().head_cpus
      )
      print(f"nthreads: {config['nthread']} xgb_model: {xgb_model}")
      # Train the classifier, using the Tune callback
      xgb.train(
          config,
          train_set,
          evals=[(test_set, "eval")],
          verbose_eval=False,
          xgb_model=xgb_model,
          callbacks=[
              TuneReportCheckpointCallback(
                  filename=CHECKPOINT_FILENAME,
                  # checkpointing should happen every iteration
                  # with dynamic resource allocation
                  frequency=1,
              )
          ],
      )
  
imports: from typing import Dict, Any, Optional, TYPE_CHECKING
  import sklearn.datasets
  import sklearn.metrics
  import os
  from sklearn.model_selection import train_test_split
  import xgboost
  from xgboost.core import Booster
  import pickle
  import ray
  from ray import train, tune
  from ray.tune.schedulers import ResourceChangingScheduler, ASHAScheduler
  from ray.tune import Trainable
  from ray.tune.execution.placement_groups import PlacementGroupFactory
  from ray.tune.experiment import Trial
  from ray.tune.integration.xgboost import TuneReportCheckpointCallback
label_desc: Use image node_id 2 for calling a global function with example usage: train_breast_cancer(config) without return types