class_docstr: `AugmentedLSTM` implements a generic AugmentedLSTM representation layer.
  AugmentedLSTM is an LSTM which optionally appends
  an optional highway network to the output layer.
  Furthermore the dropout controlls the level of variational dropout done.
  
  Args:
      config (Config): Configuration object of type BiLSTM.Config.
      embed_dim (int): The number of expected features in the input.
      padding_value (float): Value for the padded elements. Defaults to 0.0.
  
  Attributes:
      padding_value (float): Value for the padded elements.
      forward_layers (nn.ModuleList): A module list of unidirectional AugmentedLSTM
          layers moving forward in time.
      backward_layers (nn.ModuleList): A module list of unidirectional AugmentedLSTM
          layers moving backward in time.
      representation_dim (int): The calculated dimension of the output features
          of AugmentedLSTM.
class_docstr_tok: ["`","AugmentedLSTM","`","implements","a","generic","AugmentedLSTM","representation","layer",".","AugmentedLSTM","is","an","LSTM","which","optionally","appends","an","optional","highway","network","to","the","output","layer",".","Furthermore","the","dropout","controlls","the","level","of","variational","dropout","done",".","Args",":","config","(","Config",")",":","Configuration","object","of","type","BiLSTM.Config",".","embed_dim","(","int",")",":","The","number","of","expected","features","in","the","input",".","padding_value","(","float",")",":","Value","for","the","padded","elements",".","Defaults","to","0.0",".","Attributes",":","padding_value","(","float",")",":","Value","for","the","padded","elements",".","forward_layers","(","nn.ModuleList",")",":","A","module","list","of","unidirectional","AugmentedLSTM","layers","moving","forward","in","time",".","backward_layers","(","nn.ModuleList",")",":","A","module","list","of","unidirectional","AugmentedLSTM","layers","moving","backward","in","time",".","representation_dim","(","int",")",":","The","calculated","dimension","of","the","output","features","of","AugmentedLSTM","."]
code: def _forward_bidirectional(
      self,
      inputs: PackedSequence,
      states: Optional[Tuple[torch.Tensor, torch.Tensor]],
  ):
      output_sequence = inputs
      final_h = []
      final_c = []
  
      if not states:
          hidden_states = [None] * self.num_layers
      elif states[0].size()[0] != self.num_layers:
          raise RuntimeError(
              "Initial states were passed to forward() but the number of "
              "initial states does not match the number of layers."
          )
      else:
          hidden_states = list(  # noqa
              zip(
                  states[0].chunk(self.num_layers, 0),
                  states[1].chunk(self.num_layers, 0),
              )
          )
      for i, state in enumerate(hidden_states):
          if state:
              forward_state = state[0].chunk(2, -1)
              backward_state = state[1].chunk(2, -1)
          else:
              forward_state = backward_state = None
  
          forward_layer = self.forward_layers[i]
          backward_layer = self.backward_layers[i]
          # The state is duplicated to mirror the Pytorch API for LSTMs.
          forward_output, final_forward_state = forward_layer(
              output_sequence, forward_state
          )
          backward_output, final_backward_state = backward_layer(
              output_sequence, backward_state
          )
          forward_output, lengths = pad_packed_sequence(
              forward_output, batch_first=True
          )
          backward_output, _ = pad_packed_sequence(
              backward_output, batch_first=True
          )
          output_sequence = torch.cat(
              [forward_output, backward_output], -1
          )
          output_sequence = pack_padded_sequence(
              output_sequence, lengths, batch_first=True
          )
  
          final_h.extend(
              [final_forward_state[0], final_backward_state[0]]
          )
          final_c.extend(
              [final_forward_state[1], final_backward_state[1]]
          )
  
      final_h = torch.cat(final_h, dim=0).transpose(0, 1)
      final_c = torch.cat(final_c, dim=0).transpose(0, 1)
      final_state_tuple = (final_h, final_c)
      output_sequence, _ = pad_packed_sequence(
          output_sequence,
          padding_value=self.padding_value,
          batch_first=True,
      )
      return output_sequence, final_state_tuple
  
imports: import math
  from typing import Optional, Tuple
  import torch
  import torch.nn
  from pytext.config import ConfigBase
  from pytext.utils.usage import log_class_usage
  from torch.nn.utils.rnn import pack_padded_sequence, PackedSequence, pad_packed_sequence
  from .representation_base import RepresentationBase
label_desc: Use image node_id 3 for calling the AugmentedLSTM obj's underlying member method code with example usage: obj._forward_bidirectional(inputs, states) and returns: output_sequence,  final_state_tuple