code: def __init__(
      self,
      ml_task,
      X_train,
      y_train,
      sample_weight,
      X_validation,
      y_validation,
      sample_weight_validation,
      eval_metric,
      n_jobs,
      random_state,
  ):
      self.dtrain = xgb.DMatrix(
          X_train, label=y_train, weight=sample_weight
      )
      self.dvalidation = xgb.DMatrix(
          X_validation,
          label=y_validation,
          weight=sample_weight_validation,
      )
      self.X_validation = X_validation
      self.y_validation = y_validation
      self.eval_metric = eval_metric
      self.n_jobs = n_jobs
  
      self.learning_rate = 0.0125
      self.rounds = 1000
      self.early_stopping_rounds = 50
      self.seed = random_state
  
      self.objective = ""
      self.eval_metric_name = ""
      self.num_class = (
          len(np.unique(y_train))
          if ml_task == MULTICLASS_CLASSIFICATION
          else None
      )
  
      self.objective = xgboost_objective(ml_task, eval_metric.name)
      self.eval_metric_name = xgboost_eval_metric(
          ml_task, eval_metric.name
      )
  
      self.custom_eval_metric = None
      if self.eval_metric_name == "r2":
          self.custom_eval_metric = xgboost_eval_metric_r2
      elif self.eval_metric_name == "spearman":
          self.custom_eval_metric = xgboost_eval_metric_spearman
      elif self.eval_metric_name == "pearson":
          self.custom_eval_metric = xgboost_eval_metric_pearson
      elif self.eval_metric_name == "f1":
          self.custom_eval_metric = xgboost_eval_metric_f1
      elif self.eval_metric_name == "average_precision":
          self.custom_eval_metric = (
              xgboost_eval_metric_average_precision
          )
      elif self.eval_metric_name == "accuracy":
          self.custom_eval_metric = xgboost_eval_metric_accuracy
      elif self.eval_metric_name == "mse":
          self.custom_eval_metric = xgboost_eval_metric_mse
      elif self.eval_metric_name == "user_defined_metric":
          self.custom_eval_metric = xgboost_eval_metric_user_defined
  
file_path: mljar-supervised/supervised/tuner/optuna/xgboost.py
imports: import numpy
  import optuna
  import xgboost
  from supervised.algorithms.registry import BINARY_CLASSIFICATION, MULTICLASS_CLASSIFICATION, REGRESSION
  from supervised.algorithms.xgboost import xgboost_eval_metric, xgboost_objective
  from supervised.utils.metric import Metric, xgboost_eval_metric_accuracy, xgboost_eval_metric_average_precision, xgboost_eval_metric_f1, xgboost_eval_metric_mse, xgboost_eval_metric_pearson, xgboost_eval_metric_r2, xgboost_eval_metric_spearman, xgboost_eval_metric_user_defined
label_desc: Use image node_id 1 to create a new XgboostObjective object  with example: obj = XgboostObjective(ml_task, X_train, y_train, sample_weight, X_validation, y_validation, sample_weight_validation, eval_metric, n_jobs, random_state)