code: def __init__(
      self,
      config: GBMTrainerConfig,
      model: GBM,
      resume: float = False,
      skip_save_model: bool = False,
      skip_save_progress: bool = False,
      skip_save_log: bool = False,
      callbacks: List = None,
      report_tqdm_to_ray=False,
      random_seed: float = default_random_seed,
      distributed: Optional[DistributedStrategy] = None,
      device: Optional[str] = None,
      **kwargs,
  ):
      super().__init__()
  
      self.random_seed = random_seed
      self.model = model
      self.distributed = (
          distributed if distributed is not None else LocalStrategy()
      )
      self.received_sigint = False
      self.report_tqdm_to_ray = report_tqdm_to_ray
      self.callbacks = callbacks or []
      self.skip_save_progress = skip_save_progress
      self.skip_save_log = skip_save_log
      self.skip_save_model = skip_save_model
  
      self.eval_batch_size = config.eval_batch_size
      self._validation_field = config.validation_field
      self._validation_metric = config.validation_metric
      self.evaluate_training_set = config.evaluate_training_set
      self.skip_all_evaluation = config.skip_all_evaluation
      try:
          base_learning_rate = float(config.learning_rate)
      except ValueError:
          base_learning_rate = (
              0.001  # Default initial learning rate for autoML.
          )
      self.base_learning_rate = base_learning_rate
      self.early_stop = config.early_stop
  
      self.boosting_type = config.boosting_type
      self.tree_learner = config.tree_learner
      self.num_boost_round = config.num_boost_round
      self.boosting_rounds_per_checkpoint = min(
          self.num_boost_round, config.boosting_rounds_per_checkpoint
      )
      self.max_depth = config.max_depth
      self.num_leaves = config.num_leaves
      self.min_data_in_leaf = config.min_data_in_leaf
      self.min_sum_hessian_in_leaf = config.min_sum_hessian_in_leaf
      self.feature_fraction = config.feature_fraction
      self.bagging_fraction = config.bagging_fraction
      self.pos_bagging_fraction = config.pos_bagging_fraction
      self.neg_bagging_fraction = config.neg_bagging_fraction
      self.bagging_seed = config.bagging_seed
      self.bagging_freq = config.bagging_freq
      self.feature_fraction_bynode = config.feature_fraction_bynode
      self.feature_fraction_seed = config.feature_fraction_seed
      self.extra_trees = config.extra_trees
      self.extra_seed = config.extra_seed
      self.max_delta_step = config.max_delta_step
      self.lambda_l1 = config.lambda_l1
      self.lambda_l2 = config.lambda_l2
      self.linear_lambda = config.linear_lambda
      self.min_gain_to_split = config.min_gain_to_split
      self.drop_rate = config.drop_rate
      self.max_drop = config.max_drop
      self.skip_drop = config.skip_drop
      self.xgboost_dart_mode = config.xgboost_dart_mode
      self.uniform_drop = config.uniform_drop
      self.drop_seed = config.drop_seed
      self.top_rate = config.top_rate
      self.other_rate = config.other_rate
      self.min_data_per_group = config.min_data_per_group
      self.max_cat_threshold = config.max_cat_threshold
      self.cat_l2 = config.cat_l2
      self.cat_smooth = config.cat_smooth
      self.max_cat_to_onehot = config.max_cat_to_onehot
      self.cegb_tradeoff = config.cegb_tradeoff
      self.cegb_penalty_split = config.cegb_penalty_split
      self.path_smooth = config.path_smooth
      self.verbose = config.verbose
      self.max_bin = config.max_bin
      self.feature_pre_filter = config.feature_pre_filter
  
      if self.boosting_type == "goss" and self.bagging_freq != 0:
          logger.info(
              "Bagging is not compatible with the GOSS boosting type. Disabling bagging for this training session."
          )
          self.bagging_freq = 0
  
      self.device = device
      if self.device is None:
          self.device = "cuda" if torch.cuda.is_available() else "cpu"
  
      # when training starts the sigint handler will be replaced with
      # set_steps_to_1_or_quit so this is needed to remember
      # the original sigint to restore at the end of training
      # and before set_steps_to_1_or_quit returns
      self.original_sigint_handler = None
  
imports: import logging
  import os
  import re
  import signal
  import sys
  import threading
  import time
  from typing import Any, Dict, List, Optional, Tuple, Union
  import lightgbm
  import torch
  from torch.utils.tensorboard import SummaryWriter
  from ludwig.constants import BINARY, CATEGORY, MINIMIZE, MODEL_GBM, NUMBER, TEST, TRAINING, VALIDATION
  from ludwig.distributed import init_dist_strategy
  from ludwig.distributed.base import DistributedStrategy, LocalStrategy
  from ludwig.features.feature_utils import LudwigFeatureDict
  from ludwig.globals import is_progressbar_disabled, TRAINING_CHECKPOINTS_DIR_PATH, TRAINING_PROGRESS_TRACKER_FILE_NAME
  from ludwig.models.gbm import GBM
  from ludwig.models.predictor import Predictor
  from ludwig.modules.metric_modules import get_improved_fn, get_initial_validation_value
  from ludwig.modules.metric_registry import get_metric_objective
  from ludwig.progress_bar import LudwigProgressBar
  from ludwig.schema.trainer import BaseTrainerConfig, GBMTrainerConfig
  from ludwig.trainers.base import BaseTrainer
  from ludwig.trainers.registry import register_ray_trainer, register_trainer
  from ludwig.types import ModelConfigDict
  from ludwig.utils import time_utils
  from ludwig.utils.checkpoint_utils import CheckpointManager
  from ludwig.utils.defaults import default_random_seed
  from ludwig.utils.gbm_utils import get_single_output_feature, get_targets, log_loss_objective, logits_to_predictions, multiclass_objective, store_predictions, store_predictions_ray, TrainLogits
  from ludwig.utils.metric_utils import get_metric_names, TrainerMetric
  from ludwig.utils.metrics_printed_table import print_metrics_table
  from ludwig.utils.misc_utils import set_random_seed
  from ludwig.utils.trainer_utils import append_metrics, get_latest_metrics_dict, get_new_progress_tracker, ProgressTracker
label_desc: Use image node_id 1 to create a new LightGBMTrainer object from inherited base classes: BaseTrainer with example: obj = LightGBMTrainer(config, model, resume, skip_save_model, skip_save_progress, skip_save_log, callbacks, report_tqdm_to_ray, random_seed, distributed, device)