class_docstr: Entropy of the predicted distribution. Defined as:
      H[P(Y|X)] = - sum_i P(Y_i|X) * log P(Y_i|X)
class_docstr_tok: ["Entropy","of","the","predicted","distribution",".","Defined","as",":","H","[","P","(","Y|X",")","]","=","-","sum_i","P","(","Y_i|X",")","*","log","P","(","Y_i|X",")"]
code: def __call__(self, logits, targets, reduce=True):
      mask = targets.ne(self.ignore_index)
  
      loss = -torch.sum(logits * logits.exp(), dim=1)
  
      if reduce:
          return (
              loss[mask].mean()
              if mask.any()
              else torch.tensor(0.0, device=logits.device)
          )
  
      return loss
  
file_path: pytext/pytext/loss/regularizer.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from pytext.config import ConfigBase
  from .loss import Loss
label_desc: Use image node_id 1 for calling the EntropyRegularizer obj's underlying member method code with example usage: obj.__call__(logits, targets, reduce) and returns: loss, unknown