class_docstr: A long short-term memory (LSTM) cell with attention.
class_docstr_tok: ["A","long","short-term","memory","(","LSTM",")","cell","with","attention","."]
docstr: Initialize params.
docstr_tok: ["Initialize","params","."]
code: def __init__(
      self, input_size, hidden_size, batch_first=True, attn_type="soft"
  ):
      """Initialize params."""
      super(LSTMAttention, self).__init__()
      self.input_size = input_size
      self.hidden_size = hidden_size
      self.batch_first = batch_first
  
      self.lstm_cell = nn.LSTMCell(input_size, hidden_size)
  
      if attn_type == "soft":
          self.attention_layer = SoftDotAttention(hidden_size)
      elif attn_type == "mlp":
          self.attention_layer = BasicAttention(hidden_size)
      elif attn_type == "linear":
          self.attention_layer = LinearAttention(hidden_size)
      elif attn_type == "deep":
          self.attention_layer = DeepAttention(hidden_size)
      else:
          raise Exception(
              "Unsupported LSTM attention type: {}".format(attn_type)
          )
      logger.debug("Using {} attention for LSTM.".format(attn_type))
  
imports: import logging
  import torch
  import torch.nn
  import math
  import numpy
  import stanza.models.common.seq2seq_constant
label_desc: Use image node_id 1 to create a new LSTMAttention object from inherited base classes: nn with example: obj = LSTMAttention(input_size, hidden_size, batch_first, attn_type)