class_docstr: `BiLSTMDocAttention` implements a multi-layer bidirectional LSTM based
  representation for documents with or without pooling. The pooling can be
  max pooling, mean pooling or self attention.
  
  Args:
      config (Config): Configuration object of type BiLSTMDocAttention.Config.
      embed_dim (int): The number of expected features in the input.
  
  Attributes:
      dropout (nn.Dropout): Dropout layer preceding the LSTM.
      lstm (nn.Module): Module that implements the LSTM.
      attention (nn.Module): Module that implements the attention or pooling.
      dense (nn.Module): Module that implements the non-linear projection over
          attended representation.
      representation_dim (int): The calculated dimension of the output features
          of the `BiLSTMDocAttention` representation.
class_docstr_tok: ["`","BiLSTMDocAttention","`","implements","a","multi-layer","bidirectional","LSTM","based","representation","for","documents","with","or","without","pooling",".","The","pooling","can","be","max","pooling",",","mean","pooling","or","self","attention",".","Args",":","config","(","Config",")",":","Configuration","object","of","type","BiLSTMDocAttention.Config",".","embed_dim","(","int",")",":","The","number","of","expected","features","in","the","input",".","Attributes",":","dropout","(","nn.Dropout",")",":","Dropout","layer","preceding","the","LSTM",".","lstm","(","nn.Module",")",":","Module","that","implements","the","LSTM",".","attention","(","nn.Module",")",":","Module","that","implements","the","attention","or","pooling",".","dense","(","nn.Module",")",":","Module","that","implements","the","non-linear","projection","over","attended","representation",".","representation_dim","(","int",")",":","The","calculated","dimension","of","the","output","features","of","the","`","BiLSTMDocAttention","`","representation","."]
docstr: Given an input batch of sequential data such as word embeddings, produces
  a bidirectional LSTM representation with or without pooling of the
  sequential input and new state tensors.
  
  Args:
      embedded_tokens (torch.Tensor): Input tensor of shape
          (bsize x seq_len x input_dim).
      seq_lengths (torch.Tensor): List of sequences lengths of each batch element.
      states (Tuple[torch.Tensor, torch.Tensor]): Tuple of tensors containing
          the initial hidden state and the cell state of each element in
          the batch. Each of these tensors have a dimension of
          (bsize x num_layers * num_directions x nhid). Defaults to `None`.
  
  Returns:
      Tuple[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]: Bidirectional
          LSTM representation of input and the state of the LSTM at `t = seq_len`.
docstr_tok: ["Given","an","input","batch","of","sequential","data","such","as","word","embeddings",",","produces","a","bidirectional","LSTM","representation","with","or","without","pooling","of","the","sequential","input","and","new","state","tensors",".","Args",":","embedded_tokens","(","torch.Tensor",")",":","Input","tensor","of","shape","(","bsize","x","seq_len","x","input_dim",")",".","seq_lengths","(","torch.Tensor",")",":","List","of","sequences","lengths","of","each","batch","element",".","states","(","Tuple","[","torch.Tensor",",","torch.Tensor","]",")",":","Tuple","of","tensors","containing","the","initial","hidden","state","and","the","cell","state","of","each","element","in","the","batch",".","Each","of","these","tensors","have","a","dimension","of","(","bsize","x","num_layers","*","num_directions","x","nhid",")",".","Defaults","to","`","None","`",".","Returns",":","Tuple","[","torch.Tensor",",","Tuple","[","torch.Tensor",",","torch.Tensor","]","]",":","Bidirectional","LSTM","representation","of","input","and","the","state","of","the","LSTM","at","`","t","=","seq_len","`","."]
code: def forward(
      self,
      embedded_tokens: torch.Tensor,
      seq_lengths: torch.Tensor,
      *args,
      states: Tuple[torch.Tensor, torch.Tensor] = None,
  ) -> Tuple[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]:
      """
      Given an input batch of sequential data such as word embeddings, produces
      a bidirectional LSTM representation with or without pooling of the
      sequential input and new state tensors.
  
      Args:
          embedded_tokens (torch.Tensor): Input tensor of shape
              (bsize x seq_len x input_dim).
          seq_lengths (torch.Tensor): List of sequences lengths of each batch element.
          states (Tuple[torch.Tensor, torch.Tensor]): Tuple of tensors containing
              the initial hidden state and the cell state of each element in
              the batch. Each of these tensors have a dimension of
              (bsize x num_layers * num_directions x nhid). Defaults to `None`.
  
      Returns:
          Tuple[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]: Bidirectional
              LSTM representation of input and the state of the LSTM at `t = seq_len`.
      """
      embedded_tokens = self.dropout(embedded_tokens)
  
      # LSTM representation
      rep, new_state = self.lstm(embedded_tokens, seq_lengths, states)
  
      # Attention
      if self.attention:
          rep = self.attention(rep, seq_lengths)
  
      # Non-linear projection
      if self.dense:
          rep = self.dense(rep)
  
      return rep, new_state
  
file_path: pytext/pytext/models/representations/bilstm_doc_attention.py
imports: from typing import Optional, Tuple, Union
  import torch
  import torch.nn
  from pytext.models.decoders.mlp_decoder import MLPDecoder
  from pytext.models.module import create_module
  from pytext.models.representations.bilstm import BiLSTM
  from pytext.utils.usage import log_class_usage
  from .pooling import LastTimestepPool, MaxPool, MeanPool, NoPool, SelfAttention
  from .representation_base import RepresentationBase
label_desc: Use image node_id 2 for calling the BiLSTMDocAttention obj's underlying member method code with example usage: obj.forward(embedded_tokens, seq_lengths) and returns: rep,  new_state