class_docstr: The UnifiedInformationExplainer for returning explanations for pytorch NN models.
      
class_docstr_tok: ["The","UnifiedInformationExplainer","for","returning","explanations","for","pytorch","NN","models","."]
docstr: Calculate loss:
      $L(sigma) = (||Phi(embed + epsilon) - Phi(embed)||_2^2)
      // (regularization^2) - rate * log(sigma)$
  :return: a scalar, the target loss.
  :rtype: torch.FloatTensor
docstr_tok: ["Calculate","loss",":","$","L","(","sigma",")","=","(","||Phi","(","embed","+","epsilon",")","-","Phi","(","embed",")","||_2^2",")","\/\/","(","regularization^2",")","-","rate","*","log","(","sigma",")","$",":","return",":","a","scalar",",","the","target","loss",".",":","rtype",":","torch.FloatTensor"]
code: def forward(self):
      """Calculate loss:
          $L(sigma) = (||Phi(embed + epsilon) - Phi(embed)||_2^2)
          // (regularization^2) - rate * log(sigma)$
      :return: a scalar, the target loss.
      :rtype: torch.FloatTensor
      """
      ratios = torch.sigmoid(self.ratio)  # S * 1
      x = self.input_embeddings + 0.0
      x_tilde = (
          x
          + ratios
          * torch.randn(self.input_size, self.input_dimension).to(
              x.device
          )
          * self.scale
      )  # S * D
      s = self.Phi(x)  # D or S * D
      s_tilde = self.Phi(x_tilde)
      loss = (s_tilde - s) ** 2
      if self.regular is not None:
          loss = torch.mean(loss / self.regular**2)
      else:
          loss = torch.mean(loss) / torch.mean(s**2)
  
      return loss - torch.mean(torch.log(ratios)) * self.rate
  
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 4 for calling the UnifiedInformationExplainer obj's underlying member method code with example usage: obj.forward() and returns: unknown