class_docstr: LSTM-based decoder.
class_docstr_tok: ["LSTM-based","decoder","."]
code: def __init__(
      self, hidden_size: int, vocab_size: int, num_layers: int = 1
  ):
      super().__init__()
      self.hidden_size = hidden_size
      self.vocab_size = vocab_size
      self.embedding = nn.Embedding(vocab_size, hidden_size)
      self.lstm = nn.LSTM(
          hidden_size,
          hidden_size,
          batch_first=True,
          num_layers=num_layers,
      )
      self.out = nn.Linear(hidden_size, vocab_size)
  
      # Have the embedding and projection share weights.
      # This is a trick used by the Transformer, and seems to attain better loss.
      # See section 3.4 of https://arxiv.org/pdf/1706.03762.pdf.
      self.out.weight = self.embedding.weight
  
imports: import logging
  from typing import Dict, Tuple
  import torch
  import torch.nn
  from ludwig.api_annotations import DeveloperAPI
  from ludwig.constants import LOGITS, PREDICTIONS, PROBABILITIES, SEQUENCE, TEXT
  from ludwig.decoders.base import Decoder
  from ludwig.decoders.registry import register_decoder
  from ludwig.decoders.sequence_decoder_utils import get_lstm_init_state, get_rnn_init_state
  from ludwig.modules.reduction_modules import SequenceReducer
  from ludwig.schema.decoders.sequence_decoders import SequenceGeneratorDecoderConfig
  from ludwig.utils import strings_utils
label_desc: Use image node_id 1 to create a new LSTMDecoder object from inherited base classes: nn with example: obj = LSTMDecoder(hidden_size, vocab_size, num_layers)