class_docstr: A stacked, bidirectional LSTM which uses
  [`LstmCellWithProjection`'s](./lstm_cell_with_projection.md)
  with highway layers between the inputs to layers.
  The inputs to the forward and backward directions are independent - forward and backward
  states are not concatenated between layers.
  
  Additionally, this LSTM maintains its `own` state, which is updated every time
  `forward` is called. It is dynamically resized for different batch sizes and is
  designed for use with non-continuous inputs (i.e inputs which aren't formatted as a stream,
  such as text used for a language modeling task, which is how stateful RNNs are typically used).
  This is non-standard, but can be thought of as having an "end of sentence" state, which is
  carried across different sentences.
  
  [0]: https://arxiv.org/abs/1512.05287
  
  # 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.
  cell_size : `int`, required.
      The dimension of the memory cell of the `LstmCellWithProjection`.
  num_layers : `int`, required
      The number of bidirectional LSTMs to use.
  requires_grad : `bool`, optional
      If True, compute gradient of ELMo parameters for fine tuning.
  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][0].
  state_projection_clip_value : `float`, optional, (default = `None`)
      The magnitude with which to clip the hidden_state after projecting it.
  memory_cell_clip_value : `float`, optional, (default = `None`)
      The magnitude with which to clip the memory cell.
class_docstr_tok: ["A","stacked",",","bidirectional","LSTM","which","uses","[","`","LstmCellWithProjection","`","'s","]","(",".\/lstm_cell_with_projection.md",")","with","highway","layers","between","the","inputs","to","layers",".","The","inputs","to","the","forward","and","backward","directions","are","independent","-","forward","and","backward","states","are","not","concatenated","between","layers",".","Additionally",",","this","LSTM","maintains","its","`","own","`","state",",","which","is","updated","every","time","`","forward","`","is","called",".","It","is","dynamically","resized","for","different","batch","sizes","and","is","designed","for","use","with","non-continuous","inputs","(","i.e","inputs","which","are","n't","formatted","as","a","stream",",","such","as","text","used","for","a","language","modeling","task",",","which","is","how","stateful","RNNs","are","typically","used",")",".","This","is","non-standard",",","but","can","be","thought","of","as","having","an","``","end","of","sentence","''","state",",","which","is","carried","across","different","sentences",".","[","0","]",":","https",":","\/\/arxiv.org\/abs\/1512.05287","#","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",".","cell_size",":","`","int","`",",","required",".","The","dimension","of","the","memory","cell","of","the","`","LstmCellWithProjection","`",".","num_layers",":","`","int","`",",","required","The","number","of","bidirectional","LSTMs","to","use",".","requires_grad",":","`","bool","`",",","optional","If","True",",","compute","gradient","of","ELMo","parameters","for","fine","tuning",".","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","]","[","0","]",".","state_projection_clip_value",":","`","float","`",",","optional",",","(","default","=","`","None","`",")","The","magnitude","with","which","to","clip","the","hidden_state","after","projecting","it",".","memory_cell_clip_value",":","`","float","`",",","optional",",","(","default","=","`","None","`",")","The","magnitude","with","which","to","clip","the","memory","cell","."]
code: def __init__(
      self,
      input_size: int,
      hidden_size: int,
      cell_size: int,
      num_layers: int,
      requires_grad: bool = False,
      recurrent_dropout_probability: float = 0.0,
      memory_cell_clip_value: Optional[float] = None,
      state_projection_clip_value: Optional[float] = None,
  ) -> None:
      super().__init__(stateful=True)
  
      # Required to be wrapped with a `PytorchSeq2SeqWrapper`.
      self.input_size = input_size
      self.hidden_size = hidden_size
      self.num_layers = num_layers
      self.cell_size = cell_size
      self.requires_grad = requires_grad
  
      forward_layers = []
      backward_layers = []
  
      lstm_input_size = input_size
      go_forward = True
      for layer_index in range(num_layers):
          forward_layer = LstmCellWithProjection(
              lstm_input_size,
              hidden_size,
              cell_size,
              go_forward,
              recurrent_dropout_probability,
              memory_cell_clip_value,
              state_projection_clip_value,
          )
          backward_layer = LstmCellWithProjection(
              lstm_input_size,
              hidden_size,
              cell_size,
              not go_forward,
              recurrent_dropout_probability,
              memory_cell_clip_value,
              state_projection_clip_value,
          )
          lstm_input_size = hidden_size
  
          self.add_module(
              "forward_layer_{}".format(layer_index), forward_layer
          )
          self.add_module(
              "backward_layer_{}".format(layer_index), backward_layer
          )
          forward_layers.append(forward_layer)
          backward_layers.append(backward_layer)
      self.forward_layers = forward_layers
      self.backward_layers = backward_layers
  
file_path: allennlp/allennlp/modules/elmo_lstm.py
imports: import warnings
  from typing import List, Optional, Tuple, Any
  import numpy
  import torch
  from torch.nn.utils.rnn import PackedSequence, pad_packed_sequence
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.file_utils import cached_path
  from allennlp.modules.encoder_base import _EncoderBase
  from allennlp.modules.lstm_cell_with_projection import LstmCellWithProjection
label_desc: Use image node_id 1 to create a new ElmoLstm object from inherited base classes: _EncoderBase with example: obj = ElmoLstm(input_size, hidden_size, cell_size, num_layers, requires_grad, recurrent_dropout_probability, memory_cell_clip_value, state_projection_clip_value)