class_docstr: XGBoost model: https://xgboost.readthedocs.io/en/latest/
  
  Hyperparameter options: https://xgboost.readthedocs.io/en/latest/parameter.html
class_docstr_tok: ["XGBoost","model",":","https",":","\/\/xgboost.readthedocs.io\/en\/latest\/","Hyperparameter","options",":","https",":","\/\/xgboost.readthedocs.io\/en\/latest\/parameter.html"]
code: def _fit(
      self,
      X,
      y,
      X_val=None,
      y_val=None,
      time_limit=None,
      num_gpus=0,
      num_cpus=None,
      sample_weight=None,
      sample_weight_val=None,
      verbosity=2,
      **kwargs,
  ):
      # TODO: utilize sample_weight_val in early-stopping if provided
      start_time = time.time()
      ag_params = self._get_ag_params()
      params = self._get_model_params()
      if num_cpus:
          params["n_jobs"] = num_cpus
      max_category_levels = params.pop("proc.max_category_levels", 100)
      enable_categorical = params.get("enable_categorical", False)
      if enable_categorical:
          """Skip one-hot-encoding and pass categoricals directly to XGBoost"""
          self._ohe = False
      else:
          """One-hot-encode categorical features"""
          self._ohe = True
  
      if verbosity <= 2:
          verbose = False
          log_period = None
      elif verbosity == 3:
          verbose = True
          log_period = 50
      else:
          verbose = True
          log_period = 1
  
      X = self.preprocess(
          X, is_train=True, max_category_levels=max_category_levels
      )
      num_rows_train = X.shape[0]
  
      eval_set = []
      if "eval_metric" not in params:
          eval_metric = self.get_eval_metric()
          if eval_metric is not None:
              params["eval_metric"] = eval_metric
  
      if X_val is None:
          early_stopping_rounds = None
          eval_set = None
      else:
          X_val = self.preprocess(X_val, is_train=False)
          eval_set.append((X_val, y_val))
          early_stopping_rounds = ag_params.get(
              "early_stop", "adaptive"
          )
          if isinstance(early_stopping_rounds, (str, tuple, list)):
              early_stopping_rounds = self._get_early_stopping_rounds(
                  num_rows_train=num_rows_train,
                  strategy=early_stopping_rounds,
              )
  
      if num_gpus != 0:
          params["tree_method"] = "gpu_hist"
          if "gpu_id" not in params:
              params["gpu_id"] = 0
      elif "tree_method" not in params:
          params["tree_method"] = "hist"
  
      try_import_xgboost()
      from xgboost.callback import EvaluationMonitor
  
      from .callbacks import EarlyStoppingCustom
  
      if eval_set is not None and "callbacks" not in params:
          callbacks = []
          if log_period is not None:
              callbacks.append(EvaluationMonitor(period=log_period))
          callbacks.append(
              EarlyStoppingCustom(
                  early_stopping_rounds,
                  start_time=start_time,
                  time_limit=time_limit,
                  verbose=verbose,
              )
          )
          params["callbacks"] = callbacks
  
      from xgboost import XGBClassifier, XGBRegressor
  
      model_type = (
          XGBClassifier
          if self.problem_type in PROBLEM_TYPES_CLASSIFICATION
          else XGBRegressor
      )
      self.model = model_type(**params)
      import warnings
  
      with warnings.catch_warnings():
          # FIXME: v1.1: Upgrade XGBoost to 2.0.1+ to avoid deprecation warnings from Pandas 2.1+ during XGBoost fit.
          warnings.simplefilter(action="ignore", category=FutureWarning)
          self.model.fit(
              X=X,
              y=y,
              eval_set=eval_set,
              verbose=False,
              sample_weight=sample_weight,
          )
  
      bst = self.model.get_booster()
      # TODO: Investigate speed-ups from GPU inference
      # bst.set_param({"predictor": "gpu_predictor"})
  
      if eval_set is not None:
          self.params_trained["n_estimators"] = bst.best_iteration + 1
      # Don't save the callback or eval_metric objects
      self.model.set_params(callbacks=None, eval_metric=None)
  
imports: import logging
  import math
  import os
  import time
  from autogluon.common.features.types import R_BOOL, R_CATEGORY, R_FLOAT, R_INT
  from autogluon.common.utils.lite import disable_if_lite_mode
  from autogluon.common.utils.pandas_utils import get_approximate_df_mem_usage
  from autogluon.common.utils.resource_utils import ResourceManager
  from autogluon.common.utils.try_import import try_import_xgboost
  from autogluon.core.constants import BINARY, MULTICLASS, PROBLEM_TYPES_CLASSIFICATION, REGRESSION, SOFTCLASS
  from autogluon.core.models import AbstractModel
  from autogluon.core.models._utils import get_early_stopping_rounds
  from .None import xgboost_utils
  from .hyperparameters.parameters import get_param_baseline
  from .hyperparameters.searchspaces import get_default_searchspace
label_desc: Use image node_id 8 for calling the XGBoostModel obj's underlying member method code with example usage: obj._fit(X, y, X_val, y_val, time_limit, num_gpus, num_cpus, sample_weight, sample_weight_val, verbosity) without return types