class_docstr: An implementation for an explainable neural network for natural
  language processing and generating rationales used by that network.
  Based on the paper "Rethinking Cooperative Rationalization: Introspective
  Extraction and Complement Control" by Yu et. al.
docstr: Initializes the model parameters and components
          
docstr_tok: ["Initializes","the","model","parameters","and","components"]
code: def __init__(
      self,
      args,
      preprocessor,
      explainer,
      anti_explainer,
      generator,
      classifier,
  ):
      """Initializes the model parameters and components"""
      super(IntrospectiveRationaleModel, self).__init__()
      self.args = args
      self.lambda_sparsity = args.lambda_sparsity
      self.lambda_continuity = args.lambda_continuity
      self.lambda_anti = args.lambda_anti
      self.hidden_dim = args.hidden_dim
      self.input_dim = args.embedding_dim
      self.exploration_rate = args.exploration_rate
      self.lambda_acc_gap = args.lambda_acc_gap
      self.fixed_classifier = args.fixed_classifier
      self.target_sparsity = args.target_sparsity
      self.count_pieces = args.count_pieces
      self.use_cuda = args.cuda
      self.train_batch_size = args.train_batch_size
      self.test_batch_size = args.test_batch_size
      self.num_epochs = args.num_epochs
      self.lr = args.lr
      self.num_labels = args.num_labels
      self.fine_tuning = args.fine_tuning
  
      # initialize model components
      self.E_model = explainer
      self.E_anti_model = anti_explainer
      self.gen_C_model = classifier
      self.generator = generator
  
      self.preprocessor = preprocessor
  
      self.NEG_INF = -1.0e6
      self.loss_func = nn.CrossEntropyLoss(reduction="none")
      self.z_history_rewards = deque([0], maxlen=200)
      self.train_accs = []
  
      # initialize optimizers
      self._init_optimizers()
      self._init_rl_optimizers()
  
      # training_stop_thresh epochs: max number of epochs since last
      # improvement that model is allowed to train before fit() stops
      self.training_stop_thresh = 20
      self.epochs_since_improv = 0
  
      self.train_accs = []
      self.test_accs = []
      self.test_losses = []
      self.best_test_acc = 0
  
imports: import logging
  import os
  import random
  from collections import deque
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from interpret_text.experimental.common.base_text_model import BaseTextModel
  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 1 to create a new IntrospectiveRationaleModel object from inherited base classes: BaseTextModel, nn with example: obj = IntrospectiveRationaleModel(args, preprocessor, explainer, anti_explainer, generator, classifier)