class_docstr: LSTM encoder.
code: def __init__(
      self,
      dictionary,
      embed_dim=512,
      hidden_size=512,
      num_layers=1,
      dropout_in=0.1,
      dropout_out=0.1,
      bidirectional=False,
      left_pad=True,
      pretrained_embed=None,
      padding_idx=None,
      max_source_positions=DEFAULT_MAX_SOURCE_POSITIONS,
  ):
      super().__init__(dictionary)
      self.num_layers = num_layers
      self.dropout_in_module = FairseqDropout(
          dropout_in * 1.0, module_name=self.__class__.__name__
      )
      self.dropout_out_module = FairseqDropout(
          dropout_out * 1.0, module_name=self.__class__.__name__
      )
      self.bidirectional = bidirectional
      self.hidden_size = hidden_size
      self.max_source_positions = max_source_positions
  
      num_embeddings = len(dictionary)
      self.padding_idx = (
          padding_idx if padding_idx is not None else dictionary.pad()
      )
      if pretrained_embed is None:
          self.embed_tokens = Embedding(
              num_embeddings, embed_dim, self.padding_idx
          )
      else:
          self.embed_tokens = pretrained_embed
  
      self.lstm = LSTM(
          input_size=embed_dim,
          hidden_size=hidden_size,
          num_layers=num_layers,
          dropout=self.dropout_out_module.p if num_layers > 1 else 0.0,
          bidirectional=bidirectional,
      )
      self.left_pad = left_pad
  
      self.output_units = hidden_size
      if bidirectional:
          self.output_units *= 2
  
imports: from typing import Dict, List, Optional, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from fairseq import utils
  from fairseq.models import FairseqEncoder, FairseqEncoderDecoderModel, FairseqIncrementalDecoder, register_model, register_model_architecture
  from fairseq.modules import AdaptiveSoftmax, FairseqDropout
  from torch import Tensor
label_desc: Use image node_id 1 to create a new LSTMEncoder object from inherited base classes: FairseqEncoder with example: obj = LSTMEncoder(dictionary, embed_dim, hidden_size, num_layers, dropout_in, dropout_out, bidirectional, left_pad, pretrained_embed, padding_idx, max_source_positions)