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: Input:
      z_prob_ with dimensions (num_rows, length, 2)
  Output:
      z with dimensions (num_rows, length)
docstr_tok: ["Input",":","z_prob_","with","dimensions","(","num_rows",",","length",",","2",")","Output",":","z","with","dimensions","(","num_rows",",","length",")"]
code: def _generate_rationales(self, z_prob_):
      """
      Input:
          z_prob_ with dimensions (num_rows, length, 2)
      Output:
          z with dimensions (num_rows, length)
      """
      z_prob__ = z_prob_.view(
          -1, 2
      )  # dimensions (num_rows * length, 2)
  
      # sample actions
      sampler = torch.distributions.Categorical(z_prob__)
      if self.training:
          z_ = sampler.sample()  # dimensions (num_rows * p_length,)
      else:
          z_ = torch.max(z_prob__, dim=-1)[1]
  
      # z's dimensions: (num_rows, length)
      z = z_.view(z_prob_.size(0), z_prob_.size(1))
  
      if self.use_cuda:
          z = z.type(torch.cuda.FloatTensor)
      else:
          z = z.type(torch.FloatTensor)
  
      # neg log probs' dimensions: (num_rows * length,)
      neg_log_probs_ = -sampler.log_prob(z_)
      # new neg log prob dimensions (num_rows, length)
      neg_log_probs = neg_log_probs_.view(
          z_prob_.size(0), z_prob_.size(1)
      )
  
      return z, neg_log_probs
  
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 4 for calling the IntrospectiveRationaleModel obj's underlying member method code with example usage: obj._generate_rationales(z_prob_) and returns: z,  neg_log_probs