This issue is solved by using the debugger and checking the input tensor. Try to convert model and tensors to CPU in order to get a clearer error message.
After checking the tensors before embedding, I find that some elements exceed the range, especially for the case where the index starting from 0.