My model is a nn.LSTM connected to a nn.Linear. It is defined as follow:
import torch.nn as nn

class RNN(nn.Module):
  #
  #  input of shape (seq_len, batch, input_size)
  #
  
    def __init__(self, input_size, hidden_size, output_size = 1, num_layers = 1, batch_size = 1):
        super(RNN, self).__init__()
        
        self.hidden_size = hidden_size
        self.input_size = input_size
        self.batch_size = batch_size
        
        self.lstm = nn.LSTM(input_size, hidden_size, num_layers)
        
        self.mlp = nn.Linear(hidden_size, output_size)

    def forward(self, X, H=None):
      
        
        out, hidden = self.lstm(X,H)
        
        out = self.mlp(out[-1])
        
        return out, hidden

I thought the nn.LSTM module already took care of the recurrence step, since the documentation for nn.lstm say: output  of shape (seq_len, batch, num_directions * hidden_size): tensor containing the output features (h_t)from the last layer of the LSTM, for each t.
Am I missing something?