class_docstr: Sequential RNNLM.
  
  See also:
      https://github.com/pytorch/examples/blob/4581968193699de14b56527296262dd76ab43557/word_language_model/model.py
class_docstr_tok: ["Sequential","RNNLM",".","See","also",":","https",":","\/\/github.com\/pytorch\/examples\/blob\/4581968193699de14b56527296262dd76ab43557\/word_language_model\/model.py"]
docstr: Compute LM loss value from buffer sequences.
  
  Args:
      x (torch.Tensor): Input ids. (batch, len)
      t (torch.Tensor): Target ids. (batch, len)
  
  Returns:
      tuple[torch.Tensor, torch.Tensor, torch.Tensor]: Tuple of
          loss to backward (scalar),
          negative log-likelihood of t: -log p(t) (scalar) and
          the number of elements in x (scalar)
  
  Notes:
      The last two return values are used
      in perplexity: p(t)^{-n} = exp(-log p(t) / n)
docstr_tok: ["Compute","LM","loss","value","from","buffer","sequences",".","Args",":","x","(","torch.Tensor",")",":","Input","ids",".","(","batch",",","len",")","t","(","torch.Tensor",")",":","Target","ids",".","(","batch",",","len",")","Returns",":","tuple","[","torch.Tensor",",","torch.Tensor",",","torch.Tensor","]",":","Tuple","of","loss","to","backward","(","scalar",")",",","negative","log-likelihood","of","t",":","-log","p","(","t",")","(","scalar",")","and","the","number","of","elements","in","x","(","scalar",")","Notes",":","The","last","two","return","values","are","used","in","perplexity",":","p","(","t",")","^","{","-n","}","=","exp","(","-log","p","(","t",")","\/","n",")"]
code: def forward(self, x, t):
      """Compute LM loss value from buffer sequences.
  
      Args:
          x (torch.Tensor): Input ids. (batch, len)
          t (torch.Tensor): Target ids. (batch, len)
  
      Returns:
          tuple[torch.Tensor, torch.Tensor, torch.Tensor]: Tuple of
              loss to backward (scalar),
              negative log-likelihood of t: -log p(t) (scalar) and
              the number of elements in x (scalar)
  
      Notes:
          The last two return values are used
          in perplexity: p(t)^{-n} = exp(-log p(t) / n)
  
      """
      y = self._before_loss(x, None)[0]
      mask = (x != 0).to(y.dtype)
      loss = F.cross_entropy(
          y.view(-1, y.shape[-1]), t.view(-1), reduction="none"
      )
      logp = loss * mask.view(-1)
      logp = logp.sum()
      count = mask.sum()
      return logp / count, logp, count
  
file_path: espnet/espnet/nets/pytorch_backend/lm/seq_rnn.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from espnet.nets.lm_interface import LMInterface
label_desc: Use image node_id 5 for calling the SequentialRNNLM obj's underlying member method code with example usage: obj.forward(x, t) and returns: unknown,  logp,  count