I had the same problem and fixed it this way: All numerical values passed to the forward function of the module should be tensors. (to get distributed properly among GPUs)
Your code should work if you wrap ‘lengths = [3,2]’ as a tensor: ‘lengths = torch.tensor([3,2])’
Hope this helps!