I’m not sure to fully understand the use case.
How is dim1 defined in your input of shape [N, 20]? Is it the feature or temporal dimension?
In the first case, you should use x.view(-1, 1, 20), while in the latter x.view(-1, 20, 1).
Based on the definition of your LSTM, it seems that the first approach would be the valid one.