class_docstr: A long short-term memory (LSTM) cell with attention.
class_docstr_tok: ["A","long","short-term","memory","(","LSTM",")","cell","with","attention","."]
docstr: Propagate input through the network.
docstr_tok: ["Propagate","input","through","the","network","."]
code: def forward(
      self, input, hidden, ctx, ctx_mask=None, return_logattn=False
  ):
      """Propagate input through the network."""
      if self.batch_first:
          input = input.transpose(0, 1)
  
      output = []
      attn = []
      steps = range(input.size(0))
      for i in steps:
          hidden = self.lstm_cell(input[i], hidden)
          hy, cy = hidden
          h_tilde, alpha = self.attention_layer(
              hy, ctx, mask=ctx_mask, return_logattn=return_logattn
          )
          output.append(h_tilde)
          attn.append(alpha)
      output = torch.cat(output, 0).view(
          input.size(0), *output[0].size()
      )
  
      if self.batch_first:
          output = output.transpose(0, 1)
  
      if return_logattn:
          attn = torch.stack(attn, 0)
          if self.batch_first:
              attn = attn.transpose(0, 1)
          return output, hidden, attn
  
      return output, hidden
  
imports: import logging
  import torch
  import torch.nn
  import math
  import numpy
  import stanza.models.common.seq2seq_constant
label_desc: Use image node_id 2 for calling the LSTMAttention obj's underlying member method code with example usage: obj.forward(input, hidden, ctx, ctx_mask, return_logattn) and returns: output,  hidden, output,  hidden,  attn