@richard , Sorry for the typo in the provided code, the line should be this:
output, hidden_enc, hidden_dec = model(x, hidden_enc, hidden_dec)

I’ll update the line in the provided code snippet.
Also, I was able to get past the issue by making the forward pass of model taking only one argument i.e “x” and nothing else (in my provided code, removing both “hidden_enc” and “hidden_dec”) to make DataParallel return output of the correct dimensions.
Maybe this can be fixed (first reproduced ) in the upcoming versions of pytorch.