Based on the error message I guess you are using a batch size of 30, while the last batch in your training loop seems to be smaller (5 samples). The hidden state is however still initialized with the original batch size, which would raise this error.
You would have to either reinitialize the hidden with the current batch size or drop the last batch via drop_last=True in the DataLoader.
Unrelated to this issue, but here it seems you are flattening the activation to [batch_size*seq_len, hidden_size] and pass it to the linear layer:
output = lstm_out.contiguous().view(-1, self.hidden_size)
output = self.sigmoid(self.fc1(output))

However, afterwards you are reshaping it back to [batch_size, seq_len, hidden_size] and are slicing the last temp. step:
output = output.reshape(batch_size, sequence_len, -1)
output = output[:, -1]

If that’s the case, you could also index the last time step before applying the linear layer to avoid unnecessary computation.