docstr: Trains the model using the given train set.
  
  Parameters
  ----------
  train_set : PytorchTextClassificationDataset
      The dataset used for training the model.
  validation_set : PytorchTextClassificationDataset
      A validation set used for validation during training, or `None`. If `None`, the fit
      operation will split apart a subset of the train set as a validation set, whose size
      is set by `self.validation_set_size`.
  weights : np.ndarray[np.float32] or None, default=None
      Sample weights or None.
  early_stopping : EarlyStoppingHandler or 'none'
      A strategy for early stopping. Passing 'none' disables early stopping.
  model_selection : ModelSelectionHandler or 'none'
      A model selection handler. Passing 'none' disables model selection.
  optimizer : torch.optim.optimizer.Optimizer
      A pytorch optimizer.
  scheduler :torch.optim._LRScheduler
      A pytorch scheduler.
  
  Returns
  -------
  self : KimCNNClassifier
      Returns the current classifier with a fitted model.
docstr_tok: ["Trains","the","model","using","the","given","train","set",".","Parameters","--","--","--","--","--","train_set",":","PytorchTextClassificationDataset","The","dataset","used","for","training","the","model",".","validation_set",":","PytorchTextClassificationDataset","A","validation","set","used","for","validation","during","training",",","or","`","None","`",".","If","`","None","`",",","the","fit","operation","will","split","apart","a","subset","of","the","train","set","as","a","validation","set",",","whose","size","is","set","by","`","self.validation_set_size","`",".","weights",":","np.ndarray","[","np.float32","]","or","None",",","default=None","Sample","weights","or","None",".","early_stopping",":","EarlyStoppingHandler","or","'none'","A","strategy","for","early","stopping",".","Passing","'none","'","disables","early","stopping",".","model_selection",":","ModelSelectionHandler","or","'none'","A","model","selection","handler",".","Passing","'none","'","disables","model","selection",".","optimizer",":","torch.optim.optimizer.Optimizer","A","pytorch","optimizer",".","scheduler",":","torch.optim._LRScheduler","A","pytorch","scheduler",".","Returns","--","--","--","-","self",":","KimCNNClassifier","Returns","the","current","classifier","with","a","fitted","model","."]
code: def fit(
      self,
      train_set,
      validation_set=None,
      weights=None,
      early_stopping=None,
      model_selection=None,
      optimizer=None,
      scheduler=None,
  ):
      """Trains the model using the given train set.
  
      Parameters
      ----------
      train_set : PytorchTextClassificationDataset
          The dataset used for training the model.
      validation_set : PytorchTextClassificationDataset
          A validation set used for validation during training, or `None`. If `None`, the fit
          operation will split apart a subset of the train set as a validation set, whose size
          is set by `self.validation_set_size`.
      weights : np.ndarray[np.float32] or None, default=None
          Sample weights or None.
      early_stopping : EarlyStoppingHandler or 'none'
          A strategy for early stopping. Passing 'none' disables early stopping.
      model_selection : ModelSelectionHandler or 'none'
          A model selection handler. Passing 'none' disables model selection.
      optimizer : torch.optim.optimizer.Optimizer
          A pytorch optimizer.
      scheduler :torch.optim._LRScheduler
          A pytorch scheduler.
  
      Returns
      -------
      self : KimCNNClassifier
          Returns the current classifier with a fitted model.
      """
      check_training_data(train_set, validation_set, weights=weights)
  
      if weights is not None:
          sub_train, sub_valid, sub_train_weights = get_splits(
              train_set,
              validation_set,
              weights=weights,
              multi_label=self.multi_label,
              validation_set_size=self.validation_set_size,
          )
      else:
          sub_train, sub_valid = get_splits(
              train_set,
              validation_set,
              multi_label=self.multi_label,
              validation_set_size=self.validation_set_size,
          )
          sub_train_weights = None
  
      early_stopping = self._get_default_early_stopping(
          early_stopping,
          self.early_stopping,
          self.early_stopping_acc,
          1,
          kwarg_no_improvement_name="early_stopping",
      )
      model_selection = self._get_default_model_selection(
          model_selection
      )
  
      fit_optimizer = (
          optimizer if optimizer is not None else self.optimizer
      )
      fit_scheduler = (
          scheduler if scheduler is not None else self.scheduler
      )
  
      if self.multi_label:
          self.enc_ = MultiLabelBinarizer()
          labels = csr_to_list(sub_train.y)
          self.enc_ = self.enc_.fit(labels)
  
      self.class_weights_ = self.initialize_class_weights(sub_train)
      self.criterion = self._get_default_criterion(
          self.class_weights_, use_sample_weights=weights is not None
      )
  
      return self._fit_main(
          sub_train,
          sub_valid,
          sub_train_weights,
          early_stopping,
          model_selection,
          fit_optimizer,
          fit_scheduler,
      )
  
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 2 for calling the KimCNNClassifier obj's underlying member method code with example usage: obj.fit(train_set, validation_set, weights, early_stopping, model_selection, optimizer, scheduler) and returns: self