class_docstr: A max entropy loss that encourage the model to have large entropy,
  therefore giving more diverse outputs.
  
  Loss = NLLLoss + alpha * EntropyLoss
class_docstr_tok: ["A","max","entropy","loss","that","encourage","the","model","to","have","large","entropy",",","therefore","giving","more","diverse","outputs",".","Loss","=","NLLLoss","+","alpha","*","EntropyLoss"]
docstr: inputs: [N, C]
  targets: [N]
docstr_tok: ["inputs",":","[","N",",","C","]","targets",":","[","N","]"]
code: def forward(self, inputs, targets):
      """
      inputs: [N, C]
      targets: [N]
      """
      assert inputs.size(0) == targets.size(0)
      nll_loss = self.nll(inputs, targets)
      # entropy loss
      mask = targets.eq(constant.PAD_ID).unsqueeze(1).expand_as(inputs)
      masked_inputs = inputs.clone().masked_fill_(mask, 0.0)
      p = torch.exp(masked_inputs)
      ent_loss = p.mul(masked_inputs).sum() / inputs.size(
          0
      )  # average over minibatch
      loss = nll_loss + self.alpha * ent_loss
      return loss
  
file_path: stanza/stanza/models/common/loss.py
imports: import logging
  import numpy
  import torch
  import torch.nn
  import stanza.models.common.seq2seq_constant
label_desc: Use image node_id 2 for calling the MaxEntropySequenceLoss obj's underlying member method code with example usage: obj.forward(inputs, targets) and returns: loss