code: def _build_and_save_xgboost(
      model_path,
      X_train,
      y_train,
      classification=True,
      num_rounds=5,
      n_classes=2,
      xgboost_params={},
  ):
      """Trains a small xgboost classifier and saves it to model_path"""
      dtrain = xgb.DMatrix(X_train, label=y_train)
  
      # instantiate params
      params = {"eval_metric": "error", "max_depth": 25}
  
      # learning task params
      if classification:
          if n_classes == 2:
              params["objective"] = "binary:logistic"
          else:
              params["num_class"] = n_classes
              params["objective"] = "multi:softprob"
      else:
          params["objective"] = "reg:squarederror"
          params["base_score"] = 0.0
  
      params.update(xgboost_params)
      bst = xgb.train(params, dtrain, num_rounds)
      bst.save_model(model_path)
      return bst
  
imports: from sklearn.model_selection import train_test_split
  from sklearn.metrics import accuracy_score, mean_squared_error
  from sklearn.ensemble import GradientBoostingClassifier, GradientBoostingRegressor, RandomForestClassifier, RandomForestRegressor, ExtraTreesClassifier, ExtraTreesRegressor
  from sklearn.datasets import make_classification, make_regression
  from cuml.internals.import_utils import has_xgboost
  from cuml.testing.utils import array_equal, unit_param, quality_param, stress_param
  from cuml import ForestInference
  from math import ceil
  import os
  import pytest
  from cuml.internals.safe_imports import cpu_only_import
label_desc: Use image node_id 2 for calling a global function with example usage: _build_and_save_xgboost(model_path, X_train, y_train, classification, num_rounds, n_classes, xgboost_params) and returns: bst