The initial hidden state might be all zeros, so I don’t think it’s a bug.
I haven’t compared your code to the other code base, but this line of code 5 seems to confirm by assumption.
The error message states that indices should be provided as torch.long.
Could you try to cast x using x = x.long()?