class_docstr: A stacked LSTM with LSTM layers which alternate between going forwards over
  the sequence and going backwards, with highway connections between each of
  the alternating layers. This implementation is based on the description in
  `Deep Semantic Role Labelling - What works and what's next
  <https://homes.cs.washington.edu/~luheng/files/acl2017_hllz.pdf>`_ .
  
  Parameters
  ----------
  input_size : int, required
      The dimension of the inputs to the LSTM.
  hidden_size : int, required
      The dimension of the outputs of the LSTM.
  num_layers : int, required
      The number of stacked LSTMs to use.
  recurrent_dropout_probability: float, optional (default = 0.0)
      The dropout probability to be used in a dropout scheme as stated in
      `A Theoretically Grounded Application of Dropout in Recurrent Neural Networks
      <https://arxiv.org/abs/1512.05287>`_ .
  
  Returns
  -------
  output : PackedSequence
      The outputs of the interleaved LSTMs per timestep. A tensor of shape
      (batch_size, max_timesteps, hidden_size) where for a given batch
      element, all outputs past the sequence length for that batch are
      zero tensors.
class_docstr_tok: ["A","stacked","LSTM","with","LSTM","layers","which","alternate","between","going","forwards","over","the","sequence","and","going","backwards",",","with","highway","connections","between","each","of","the","alternating","layers",".","This","implementation","is","based","on","the","description","in","`","Deep","Semantic","Role","Labelling","-","What","works","and","what","'s","next","<","https",":","\/\/homes.cs.washington.edu\/~luheng\/files\/acl2017_hllz.pdf",">","`","_",".","Parameters","--","--","--","--","--","input_size",":","int",",","required","The","dimension","of","the","inputs","to","the","LSTM",".","hidden_size",":","int",",","required","The","dimension","of","the","outputs","of","the","LSTM",".","num_layers",":","int",",","required","The","number","of","stacked","LSTMs","to","use",".","recurrent_dropout_probability",":","float",",","optional","(","default","=","0.0",")","The","dropout","probability","to","be","used","in","a","dropout","scheme","as","stated","in","`","A","Theoretically","Grounded","Application","of","Dropout","in","Recurrent","Neural","Networks","<","https",":","\/\/arxiv.org\/abs\/1512.05287",">","`","_",".","Returns","--","--","--","-","output",":","PackedSequence","The","outputs","of","the","interleaved","LSTMs","per","timestep",".","A","tensor","of","shape","(","batch_size",",","max_timesteps",",","hidden_size",")","where","for","a","given","batch","element",",","all","outputs","past","the","sequence","length","for","that","batch","are","zero","tensors","."]
code: def __init__(
      self,
      input_size,
      hidden_size,
      num_layers=1,
      recurrent_dropout_probability=0,
  ):
      super(AlternatingHighwayLSTM, self).__init__()
      self.input_size = input_size
      self.hidden_size = hidden_size
      self.num_layers = num_layers
      self.recurrent_dropout_probability = recurrent_dropout_probability
      self.training = True
  
      # Input dimensions consider the fact that we do
      # all of the LSTM projections (and highway parts)
      # in a single matrix multiplication.
      input_projection_size = 6 * hidden_size
      state_projection_size = 5 * hidden_size
      bias_size = 5 * hidden_size
  
      # Here we are creating a single weight and bias with the
      # parameters for all layers unfolded into it. This is necessary
      # because unpacking and re-packing the weights inside the
      # kernel would be slow, as it would happen every time it is called.
      total_weight_size = 0
      total_bias_size = 0
      for layer in range(num_layers):
          layer_input_size = input_size if layer == 0 else hidden_size
  
          input_weights = input_projection_size * layer_input_size
          state_weights = state_projection_size * hidden_size
          total_weight_size += input_weights + state_weights
  
          total_bias_size += bias_size
  
      self.weight = Parameter(torch.FloatTensor(total_weight_size))
      self.bias = Parameter(torch.FloatTensor(total_bias_size))
      self.reset_parameters()
  
file_path: magnitude/pymagnitude/third_party/allennlp/modules/alternating_highway_lstm.py
imports: from __future__ import absolute_import
  import torch
  from torch.autograd import Function
  from torch.nn import Parameter
  from torch.nn.utils.rnn import PackedSequence, pad_packed_sequence, pack_padded_sequence
  from allennlp.nn.initializers import block_orthogonal
  from allennlp.custom_extensions._ext import highway_lstm_layer
label_desc: Use image node_id 1 to create a new AlternatingHighwayLSTM object from inherited base classes: torch.nn with example: obj = AlternatingHighwayLSTM(input_size, hidden_size, num_layers, recurrent_dropout_probability)