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,
  ):
      lgb_train = lgb.Dataset(
          X.values if isinstance(X, pd.DataFrame) else X,
          y,
          weight=sample_weight,
      )
      valid_sets = None
      if self.early_stopping_rounds == 0:
          self.model = lgb.train(
              self.learner_params,
              lgb_train,
              num_boost_round=self.rounds,
              init_model=self.model,
          )
      else:
          valid_names = None
          esr = None
          if X_validation is not None and y_validation is not None:
              valid_sets = [
                  lgb_train,
                  lgb.Dataset(
                      X_validation.values
                      if isinstance(X_validation, pd.DataFrame)
                      else X_validation,
                      y_validation,
                      weight=sample_weight_validation,
                  ),
              ]
              valid_names = ["train", "validation"]
              esr = self.early_stopping_rounds
          evals_result = {}
  
          # disable for now ...
          # boosting_rounds = self.get_boosting_rounds(lgb_train, valid_sets, esr, max_time)
  
          self.model = lgb.train(
              self.learner_params,
              lgb_train,
              num_boost_round=self.rounds,
              valid_sets=valid_sets,
              valid_names=valid_names,
              feval=self.custom_eval_metric,
              callbacks=[
                  lgb.early_stopping(esr, verbose=False),
                  lgb.record_evaluation(evals_result),
              ],
          )
  
          del lgb_train
          if valid_sets is not None:
              del valid_sets[0]
              del valid_sets
  
          if log_to_file is not None:
              metric_name = list(evals_result["train"].keys())[0]
              result = pd.DataFrame(
                  {
                      "iteration": range(
                          len(evals_result["train"][metric_name])
                      ),
                      "train": evals_result["train"][metric_name],
                      "validation": evals_result["validation"][
                          metric_name
                      ],
                  }
              )
              result.to_csv(log_to_file, index=False, header=False)
  
          if self.params["ml_task"] != REGRESSION:
              self.classes_ = np.unique(y)
  
imports: import contextlib
  import copy
  import logging
  import os
  import time
  import lightgbm
  import numpy
  import pandas
  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 lightgbm_eval_metric_accuracy, lightgbm_eval_metric_average_precision, lightgbm_eval_metric_f1, lightgbm_eval_metric_pearson, lightgbm_eval_metric_r2, lightgbm_eval_metric_spearman, lightgbm_eval_metric_user_defined
label_desc: Use image node_id 4 for calling the LightgbmAlgorithm 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