The error message points to the padding_idx, which seems to be larger than the num_embeddings.
From the docs:

If given, pads the output with the embedding vector at  padding_idx  (initialized to zeros) whenever it encounters the index.

Which means that padding_index should have a value within the num_embeddings.
How did you define num_embeddings and what are you using for padding_idx?