class_docstr: This is a wrapper over xgboost algorithm.
code: def fit(
      self,
      X,
      y,
      sample_weight=None,
      X_validation=None,
      y_validation=None,
      sample_weight_validation=None,
      log_to_file=None,
      max_time=None,
  ):
      dtrain = xgb.DMatrix(
          X.values if isinstance(X, pd.DataFrame) else X,
          label=y,
          missing=np.NaN,
          weight=sample_weight,
      )
      dvalidation = xgb.DMatrix(
          X_validation.values
          if isinstance(X_validation, pd.DataFrame)
          else X_validation,
          label=y_validation,
          missing=np.NaN,
          weight=sample_weight_validation,
      )
      evals_result = {}
  
      evals = []
      esr = None
      if X_validation is not None and y_validation is not None:
          evals = [(dtrain, "train"), (dvalidation, "validation")]
          esr = self.early_stopping_rounds
  
      # disable for now, dont have better idea how to handle time limit ...
      # looks like there is better not to limit the algorithm
      # just wait till they converge ...
      # boosting_rounds = self.get_boosting_rounds(dtrain, evals, esr, max_time)
  
      if self.custom_eval_metric is not None:
          del self.learner_params["eval_metric"]
  
      self.model = xgb.train(
          self.learner_params,
          dtrain,
          self.boosting_rounds,
          evals=evals,
          early_stopping_rounds=esr,
          evals_result=evals_result,
          verbose_eval=False,
          feval=self.custom_eval_metric
          # callbacks=[time_constraint] # callback slows down by factor ~8
      )
  
      del dtrain
      del dvalidation
  
      if log_to_file is not None:
          metric_name = list(evals_result["train"].keys())[-1]
  
          result = pd.DataFrame(
              {
                  "iteration": range(
                      len(evals_result["train"][metric_name])
                  ),
                  "train": evals_result["train"][metric_name],
                  "validation": evals_result["validation"][metric_name],
              }
          )
          # it a is custom metric
          # that is always minimized
          # we need to revert it
          if metric_name in [
              "r2",
              "spearman",
              "pearson",
              "f1",
              "average_precision",
              "accuracy",
          ]:
              result["train"] *= -1.0
              result["validation"] *= -1.0
  
          result.to_csv(log_to_file, index=False, header=False)
  
      if self.params["ml_task"] != REGRESSION:
          self.classes_ = np.unique(y)
  
      # fix high memory consumption in xgboost,
      # waiting for release with fix
      # https://github.com/dmlc/xgboost/issues/5474
      """
          # disable, for now all learners are saved to hard disk and then deleted from RAM
          with tempfile.NamedTemporaryFile() as tmp:
              self.model.save_model(tmp.name)
              del self.model
              self.model = xgb.Booster()
              self.model.load_model(tmp.name)
          """
  
imports: import copy
  import logging
  import os
  import time
  from inspect import signature
  import numpy
  import pandas
  import xgboost
  from sklearn.base import ClassifierMixin, RegressorMixin
  from supervised.algorithms.algorithm import BaseAlgorithm
  from supervised.algorithms.registry import BINARY_CLASSIFICATION, MULTICLASS_CLASSIFICATION, REGRESSION, AlgorithmsRegistry
  from supervised.utils.config import LOG_LEVEL
  from supervised.utils.metric import 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
  import tempfile
label_desc: Use image node_id 2 for calling the XgbAlgorithm obj's underlying member method code with example usage: obj.fit(X, y, sample_weight, X_validation, y_validation, sample_weight_validation, log_to_file, max_time) without return types