class_docstr: Introspective Rationale Explainer
      
class_docstr_tok: ["Introspective","Rationale","Explainer"]
docstr: Generate rationales, predictions using rationales, predictions using
  anti-rationales (complement of generated rationales), and introspective
  generator classifier predictions for given examples.
  
  :param df_predict: data containing labels, lists of word token
      ids, pad/word masks, and token counts for each testing example
  :type df_predict: pd.DataFrame
  :return: Dictionary with fields:
      "predict": predictions using generated rationales
      "anti_predict": predictions using complements of generated
          rationales
      "cls_predict": predictions from introspective generator,
      "rationale": mask indicating whether words were used in rationales,
  :rtype: dict
code: def predict(self, df_predict):
      """Generate rationales, predictions using rationales, predictions using
      anti-rationales (complement of generated rationales), and introspective
      generator classifier predictions for given examples.
  
      :param df_predict: data containing labels, lists of word token
          ids, pad/word masks, and token counts for each testing example
      :type df_predict: pd.DataFrame
      :return: Dictionary with fields:
          "predict": predictions using generated rationales
          "anti_predict": predictions using complements of generated
              rationales
          "cls_predict": predictions from introspective generator,
          "rationale": mask indicating whether words were used in rationales,
      :rtype: dict
      """
      self.model.eval()
      self.model.training = False
      batch_dict = generate_data(df_predict, self.model_config.cuda)
      batch_x_ = batch_dict["x"]
      batch_m_ = batch_dict["m"]
      forward_dict = self.model.forward(batch_x_, batch_m_)
      predict = forward_dict["predict"]
      anti_predict = forward_dict["anti_predict"]
      cls_predict = forward_dict["cls_predict"]
      z = forward_dict["z"]
      predict = predict.detach()
      anti_predict = anti_predict.detach()
      cls_predict = cls_predict.detach()
      z = z.detach()
      predict_dict = {
          "predict": predict,
          "anti_predict": anti_predict,
          "cls_predict": cls_predict,
          "rationale": z,
      }
      self.model.training = True
      return predict_dict
  
imports: from typing import Iterable, Any, Optional, Union, Dict
  import numpy
  import pandas
  import torch
  from interpret_text.experimental.common.base_explainer import BaseTextExplainer, _validate_X
  from interpret_text.experimental.common.constants import BertTokens
  from interpret_text.experimental.common.model_config.introspective_rationale_model_config import IntrospectiveRationaleModelConfig
  from interpret_text.experimental.common.model_config.model_config_constants import get_bert_default_config, get_rnn_default_config, get_bert_rnn_default_config
  from interpret_text.experimental.common.preprocessor.bert_preprocessor import BertPreprocessor
  from interpret_text.experimental.common.preprocessor.glove_preprocessor import GlovePreprocessor
  from interpret_text.experimental.common.utils_classical import plot_local_imp
  from interpret_text.experimental.common.utils_introspective_rationale import generate_data
  from interpret_text.experimental.explanation import _create_local_explanation, LocalExplanation
  from interpret_text.experimental.introspective_rationale.components import ClassifierWrapper, ClassifierModule, IntrospectionGeneratorModule
  from interpret_text.experimental.introspective_rationale.model import IntrospectiveRationaleModel
  from transformers import BertForSequenceClassification
label_desc: Use image node_id 24 for calling the IntrospectiveRationaleExplainer obj's underlying member method code with example usage: obj.predict(df_predict) and returns: predict_dict