code: def _train(
      self,
      sub_train,
      sub_valid,
      weights,
      early_stopping,
      model_selection,
      optimizer,
      scheduler,
      tmp_dir,
  ):
      stop = False
      for epoch in range(self.num_epochs):
          if not stop:
              start_time = datetime.datetime.now()
  
              self.model.train()
              train_loss, train_acc = self._train_func(
                  sub_train, weights, optimizer, scheduler
              )
  
              self.model.eval()
              valid_loss, valid_acc = self.validate(sub_valid)
  
              timedelta = datetime.datetime.now() - start_time
  
              self.logger.info(
                  f"Epoch: {epoch + 1} | {format_timedelta(timedelta)}\n"
                  f"\tTrain Set Size: {len(sub_train)}\n"
                  f"\tLoss: {train_loss:.4f}(train)\t|\tAcc: {train_acc * 100:.1f}% (train)\n"
                  f"\tLoss: {valid_loss:.4f}(valid)\t|\tAcc: {valid_acc * 100:.1f}% (valid)",
                  verbosity=VERBOSITY_MORE_VERBOSE,
              )
  
              measured_values = {
                  "train_loss": train_loss,
                  "train_acc": train_acc,
                  "val_loss": valid_loss,
                  "val_acc": valid_acc,
              }
              stop = early_stopping.check_early_stop(
                  epoch + 1, measured_values
              )
              self._save_model(
                  optimizer,
                  model_selection,
                  f"{epoch}-0",
                  train_acc,
                  train_loss,
                  valid_acc,
                  valid_loss,
                  stop,
                  tmp_dir,
              )
  
      return self
  
imports: import datetime
  import logging
  import tempfile
  import numpy
  from functools import partial
  from sklearn.preprocessing import MultiLabelBinarizer
  from small_text.classifiers.classification import EmbeddingMixin
  from small_text.integrations.pytorch.classifiers.base import PytorchClassifier
  from small_text.integrations.pytorch.exceptions import PytorchNotFoundError
  from small_text.integrations.pytorch.models.kimcnn import KimCNN
  from small_text.utils.classification import get_splits
  from small_text.utils.context import build_pbar_context
  from small_text.utils.data import check_training_data, list_length
  from small_text.utils.annotations import early_stopping_deprecation_warning
  from small_text.utils.labels import csr_to_list, get_num_labels
  from small_text.utils.datetime import format_timedelta
  from small_text.utils.logging import verbosity_logger, VERBOSITY_MORE_VERBOSE
  from small_text.utils.system import get_tmp_dir_base
label_desc: Use image node_id 6 for calling the KimCNNClassifier obj's underlying member method code with example usage: obj._train(sub_train, sub_valid, weights, early_stopping, model_selection, optimizer, scheduler, tmp_dir) and returns: self