code: def fit(
      self,
      dataset: DatasetH,
      evals_result=dict(),
      save_path=None,
  ):
      dl_train = dataset.prepare(
          "train",
          col_set=["feature", "label"],
          data_key=DataHandlerLP.DK_L,
      )
      dl_valid = dataset.prepare(
          "valid",
          col_set=["feature", "label"],
          data_key=DataHandlerLP.DK_L,
      )
  
      if dl_train.empty or dl_valid.empty:
          raise ValueError(
              "Empty data from dataset, please check your dataset config."
          )
  
      dl_train.config(
          fillna_type="ffill+bfill"
      )  # process nan brought by dataloader
      dl_valid.config(
          fillna_type="ffill+bfill"
      )  # process nan brought by dataloader
  
      train_loader = DataLoader(
          dl_train,
          batch_size=self.batch_size,
          shuffle=True,
          num_workers=self.n_jobs,
          drop_last=True,
      )
      valid_loader = DataLoader(
          dl_valid,
          batch_size=self.batch_size,
          shuffle=False,
          num_workers=self.n_jobs,
          drop_last=True,
      )
  
      save_path = get_or_create_path(save_path)
  
      stop_steps = 0
      train_loss = 0
      best_score = -np.inf
      best_epoch = 0
      evals_result["train"] = []
      evals_result["valid"] = []
  
      # train
      self.logger.info("training...")
      self.fitted = True
  
      for step in range(self.n_epochs):
          self.logger.info("Epoch%d:", step)
          self.logger.info("training...")
          self.train_epoch(train_loader)
          self.logger.info("evaluating...")
          train_loss, train_score = self.test_epoch(train_loader)
          val_loss, val_score = self.test_epoch(valid_loader)
          self.logger.info(
              "train %.6f, valid %.6f" % (train_score, val_score)
          )
          evals_result["train"].append(train_score)
          evals_result["valid"].append(val_score)
  
          if val_score > best_score:
              best_score = val_score
              stop_steps = 0
              best_epoch = step
              best_param = copy.deepcopy(self.model.state_dict())
          else:
              stop_steps += 1
              if stop_steps >= self.early_stop:
                  self.logger.info("early stop")
                  break
  
      self.logger.info(
          "best score: %.6lf @ %d" % (best_score, best_epoch)
      )
      self.model.load_state_dict(best_param)
      torch.save(best_param, save_path)
  
      if self.use_gpu:
          torch.cuda.empty_cache()
  
imports: from __future__ import division
  from __future__ import print_function
  import numpy
  import pandas
  import copy
  import math
  from ...utils import get_or_create_path
  from ...log import get_module_logger
  import torch
  import torch.nn
  import torch.optim
  from torch.utils.data import DataLoader
  from ...model.base import Model
  from ...data.dataset import DatasetH
  from ...data.dataset.handler import DataHandlerLP
label_desc: Use image node_id 8 for calling the TransformerModel obj's underlying member method code with example usage: obj.fit(dataset, evals_result, save_path) without return types