code: def tune_xgboost(use_cv: bool = False):
      search_space = {
          # You can mix constants with search space objects.
          "objective": "binary:logistic",
          "eval_metric": ["logloss", "error"],
          "max_depth": tune.randint(1, 9),
          "min_child_weight": tune.choice([1, 2, 3]),
          "subsample": tune.uniform(0.5, 1.0),
          "eta": tune.loguniform(1e-4, 1e-1),
      }
      # This will enable aggressive early stopping of bad trials.
      scheduler = ASHAScheduler(
          max_t=10,
          grace_period=1,
          reduction_factor=2,  # 10 training iterations
      )
  
      tuner = tune.Tuner(
          tune.with_resources(
              train_breast_cancer
              if not use_cv
              else train_breast_cancer_cv,
              # You can add "gpu": 0.1 to allocate GPUs
              resources={"cpu": 1},
          ),
          tune_config=tune.TuneConfig(
              metric="test-logloss",
              mode="min",
              num_samples=10,
              scheduler=scheduler,
          ),
          param_space=search_space,
      )
      results = tuner.fit()
  
      return results.get_best_result()
  
file_path: ray/python/ray/tune/examples/xgboost_example.py
imports: from typing import Dict, List
  import sklearn.datasets
  import sklearn.metrics
  import os
  import numpy
  from sklearn.model_selection import train_test_split
  import xgboost
  import ray
  from ray import tune
  from ray.tune.schedulers import ASHAScheduler
  from ray.tune.integration.xgboost import TuneReportCheckpointCallback
label_desc: Use image node_id 4 for calling a global function with example usage: tune_xgboost(use_cv) and returns: results