class_docstr: The UnifiedInformationExplainer for returning explanations for pytorch NN models.
      
class_docstr_tok: ["The","UnifiedInformationExplainer","for","returning","explanations","for","pytorch","NN","models","."]
docstr: Initialize the UnifiedInformationExplainer
  :param model: a pytorch model
  :type: torch.nn
  :param train_dataset: dataset used while training the model
  :type train_dataset: list
  :param device: A pytorch device
  :type device: torch.device
  :param target_layer: The target layer to explain. Default is 14, which is the classification layer.
  If set to -1, all layers will be explained
  :type target_layer: int
  :param max_points: The fraction of the dataset to be used when calculating the regularization
  parameter. A max of 1000 is recommended. Higher numbers will lead to slower explanations and memory issues.
  :type max_points: int
  :param classes: An iterable array containing the label classes
  :type classes: string[]
docstr_tok: ["Initialize","the","UnifiedInformationExplainer",":","param","model",":","a","pytorch","model",":","type",":","torch.nn",":","param","train_dataset",":","dataset","used","while","training","the","model",":","type","train_dataset",":","list",":","param","device",":","A","pytorch","device",":","type","device",":","torch.device",":","param","target_layer",":","The","target","layer","to","explain",".","Default","is","14",",","which","is","the","classification","layer",".","If","set","to","-1",",","all","layers","will","be","explained",":","type","target_layer",":","int",":","param","max_points",":","The","fraction","of","the","dataset","to","be","used","when","calculating","the","regularization","parameter",".","A","max","of","1000","is","recommended",".","Higher","numbers","will","lead","to","slower","explanations","and","memory","issues",".",":","type","max_points",":","int",":","param","classes",":","An","iterable","array","containing","the","label","classes",":","type","classes",":","string","[","]"]
code: def __init__(
      self,
      model,
      train_dataset,
      device,
      target_layer=14,
      max_points=1000,
      classes=None,
  ):
      """Initialize the UnifiedInformationExplainer
      :param model: a pytorch model
      :type: torch.nn
      :param train_dataset: dataset used while training the model
      :type train_dataset: list
      :param device: A pytorch device
      :type device: torch.device
      :param target_layer: The target layer to explain. Default is 14, which is the classification layer.
      If set to -1, all layers will be explained
      :type target_layer: int
      :param max_points: The fraction of the dataset to be used when calculating the regularization
      parameter. A max of 1000 is recommended. Higher numbers will lead to slower explanations and memory issues.
      :type max_points: int
      :param classes: An iterable array containing the label classes
      :type classes: string[]
      """
      super(UnifiedInformationExplainer, self).__init__()
      self.device = device
      # Constant paramters for now, will modify based on the model later
      # Scale: The maximum size of sigma. A hyper-parameter in reparameterization trick. Larger scale will
      # give more salient result, Default: 0.5.
      self.scale = 0.5
      # Rate: A hyper-parameter that balance the MLE Loss and Maximum Entropy Loss. Larger rate will result in
      # larger information loss. Default: 0.1.
      self.rate = 0.1
      # Phi: A function whose input is x (element in the first parameter) and returns a hidden state (of type
      # ``torch.FloatTensor``, of any shape
      self.Phi = None
      self.regular = None
      self.max_points = max_points
      self.target_layer = target_layer
      self.model = model
      self.train_dataset = train_dataset
      self.classes = classes
  
      assert (
          self.train_dataset is not None
      ), "Training dataset is required. please pass in the data used to train\
              the model"
      assert (
          self.model is not None
      ), "You have to pass in a trained model."
      assert (
          self.scale >= 0
      ), "The value for scale cannot be less than zero"
      assert (
          1 >= self.rate >= 0
      ), "The value for rate has to be between 0 and 1"
      assert isinstance(self.target_layer, int) and (
          1 <= self.target_layer <= 14
      ), """the\
              value of the target layer has to be an interger between 1 to 12 (specific bert\
              layer) or 13 (pooler layer), or 14 (final classification layer).\
              You want to access layer %d""" % (
          self.target_layer
      )
  
imports: import torch
  from torch import nn, optim
  from tqdm import tqdm
  import numpy
  import random
  import html
  import matplotlib.pyplot
  from IPython.core.display import display, HTML
  from interpret_text.experimental.common.base_explainer import _validate_X
  from interpret_text.experimental.common.structured_model_mixin import PureStructuredModelMixin
  from interpret_text.experimental.explanation import _create_local_explanation
  from interpret_text.experimental.common.utils_unified import _get_single_embedding, make_bert_embeddings
label_desc: Use image node_id 1 to create a new UnifiedInformationExplainer object from inherited base classes: PureStructuredModelMixin, nn with example: obj = UnifiedInformationExplainer(model, train_dataset, device, target_layer, max_points, classes)