class_docstr: Wrapper to provide a common interfaces among different classifier modules
      
class_docstr_tok: ["Wrapper","to","provide","a","common","interfaces","among","different","classifier","modules"]
docstr: Train the classifier on the training data, with testing
  at the end of every epoch.
  
  :param df_train: training data containing labels, lists of word token
  ids, pad/word masks, and token counts for each training example
  :type df_train: pd.DataFrame
  :param df_test: testing data containing labels, lists of word token
  ids, pad/word masks, and token counts for each testing example
  :type df_test: pd.DataFrame
docstr_tok: ["Train","the","classifier","on","the","training","data",",","with","testing","at","the","end","of","every","epoch",".",":","param","df_train",":","training","data","containing","labels",",","lists","of","word","token","ids",",","pad\/word","masks",",","and","token","counts","for","each","training","example",":","type","df_train",":","pd.DataFrame",":","param","df_test",":","testing","data","containing","labels",",","lists","of","word","token","ids",",","pad\/word","masks",",","and","token","counts","for","each","testing","example",":","type","df_test",":","pd.DataFrame"]
code: def fit(self, df_train, df_test):
      """Train the classifier on the training data, with testing
      at the end of every epoch.
  
      :param df_train: training data containing labels, lists of word token
      ids, pad/word masks, and token counts for each training example
      :type df_train: pd.DataFrame
      :param df_test: testing data containing labels, lists of word token
      ids, pad/word masks, and token counts for each testing example
      :type df_test: pd.DataFrame
      """
      self.init_optimizer()
  
      total_train = len(df_train)
      indices = np.array(list(range(0, total_train)))
  
      for i in tqdm(range(self.num_epochs)):
          self.model.train()  # pytorch fn; sets module to train mode
  
          # shuffle the epoch
          np.random.shuffle(indices)
  
          total_train_acc = 0
          for i in range(total_train // self.args.train_batch_size):
              # sample a batch of data
              start = i * self.args.train_batch_size
              end = min(
                  (i + 1) * self.args.train_batch_size, total_train
              )
              batch = df_train.loc[indices[start:end]]
              batch_dict = generate_data(batch, self.args.cuda)
              batch_x_ = batch_dict["x"]
              batch_m_ = batch_dict["m"]
              batch_y_ = batch_dict["y"]
  
              losses, predict = self._train_one_step(
                  batch_x_, batch_y_, batch_m_
              )
  
              # calculate classification accuarcy
              _, y_pred = torch.max(predict, dim=1)
  
              acc = np.float(
                  (y_pred == batch_y_).sum().cpu().data.item()
              )
              total_train_acc += acc
  
          total_acc_percent = total_train_acc / total_train
          self.train_accs.append(total_acc_percent)
  
          self.test(df_test)
          # stop training if there have been no improvements
          if self.epochs_since_improv > self.args.training_stop_thresh:
              break
  
imports: import os
  import logging
  import numpy
  import torch
  import torch.nn
  from torch.autograd import Variable
  from tqdm import tqdm
  from interpret_text.experimental.common.utils_introspective_rationale import generate_data
label_desc: Use image node_id 5 for calling the ClassifierWrapper obj's underlying member method code with example usage: obj.fit(df_train, df_test) without return types