You have 3 ways of approaching this



nn.LSTM(input_size, hidden_size, num_layers=2)

num_layers=2 would mean stacking two LSTMs together to form a stacked LSTM,



self.rnn = nn.Sequential(OrderedDict([
    ('LSTM1', nn.LSTM(n_features, self.hidden_dim, 1),
    ('LSTM2', nn.LSTM(self.hidden_dim, embedding_dim, 1)
]))




self.rnns = nn.ModuleList()
for i in range(nlayers):
    input_size = input_size if i == 0 else hidden_size
    rnns.append(nn.LSTM(input_size, hidden_size, 1))

Limitation of the first  2 approaches, you can’t get the hidden states of each individual layer.