After padding, I will need to use something like the following (from the 2nd link):
        X = torch.nn.utils.rnn.pack_padded_sequence(x, **X_lengths**, batch_first=True)

        # now run through LSTM
        X, self.hidden = self.lstm(X, self.hidden)

        # undo the packing operation
        X, _ = torch.nn.utils.rnn.pad_packed_sequence(X, batch_first=True)

The X_length parameter is needed for the RNN to ignore the padded parts, and it’s passed to the forward function. I have no problem calculating it for the entire dataset, but how do I pass it if I choose to batch the data?
I though of using the collate function and returning the length for each batch, but than how is it passed to the forward function of the module?