code: def __init__(self, params):
      super(LightgbmAlgorithm, self).__init__(params)
      self.library_version = lgb.__version__
  
      self.explain_level = params.get("explain_level", 0)
      self.rounds = additional.get("max_rounds", 10000)
      self.max_iters = 1
      self.early_stopping_rounds = additional.get(
          "early_stopping_rounds", 50
      )
  
      n_jobs = self.params.get("n_jobs", 0)
      # 0 is the default for LightGBM to use all cores
      if n_jobs == -1:
          n_jobs = 0
  
      self.learner_params = {
          "boosting_type": "gbdt",
          "objective": self.params.get("objective", "binary"),
          "metric": self.params.get("metric", "binary_logloss"),
          "num_leaves": self.params.get("num_leaves", 31),
          "learning_rate": self.params.get("learning_rate", 0.1),
          "feature_fraction": self.params.get("feature_fraction", 1.0),
          "bagging_fraction": self.params.get("bagging_fraction", 1.0),
          "min_data_in_leaf": self.params.get("min_data_in_leaf", 20),
          "num_threads": n_jobs,
          "verbose": -1,
          "seed": self.params.get("seed", 1),
          "extra_trees": self.params.get("extra_trees", False),
      }
  
      for extra_param in [
          "lambda_l1",
          "lambda_l2",
          "bagging_freq",
          "feature_pre_filter",
          "cat_feature",
          "cat_l2",
          "cat_smooth",
          "max_bin",
      ]:
          if extra_param in self.params:
              self.learner_params[extra_param] = self.params[
                  extra_param
              ]
  
      if "num_boost_round" in self.params:
          self.rounds = self.params["num_boost_round"]
      if "early_stopping_rounds" in self.params:
          self.early_stopping_rounds = self.params[
              "early_stopping_rounds"
          ]
  
      if "num_class" in self.params:  # multiclass classification
          self.learner_params["num_class"] = self.params.get(
              "num_class"
          )
  
      self.custom_eval_metric = None
      if self.params.get("custom_eval_metric_name") is not None:
          if self.params["custom_eval_metric_name"] == "r2":
              self.custom_eval_metric = lightgbm_eval_metric_r2
          elif self.params["custom_eval_metric_name"] == "spearman":
              self.custom_eval_metric = lightgbm_eval_metric_spearman
          elif self.params["custom_eval_metric_name"] == "pearson":
              self.custom_eval_metric = lightgbm_eval_metric_pearson
          elif self.params["custom_eval_metric_name"] == "f1":
              self.custom_eval_metric = lightgbm_eval_metric_f1
          elif (
              self.params["custom_eval_metric_name"]
              == "average_precision"
          ):
              self.custom_eval_metric = (
                  lightgbm_eval_metric_average_precision
              )
          elif self.params["custom_eval_metric_name"] == "accuracy":
              self.custom_eval_metric = lightgbm_eval_metric_accuracy
          elif (
              self.params["custom_eval_metric_name"]
              == "user_defined_metric"
          ):
              self.custom_eval_metric = (
                  lightgbm_eval_metric_user_defined
              )
  
      logger.debug("LightgbmLearner __init__")
  
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 1 to create a new LightgbmAlgorithm object from inherited base classes: BaseAlgorithm with example: obj = LightgbmAlgorithm(params)