The indexing error is raised in:
return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)

so check the min and max values of input and make sure they match the weight dimension, i.e. the input should contain values in [0, num_embeddings-1].
Here is an example of a working and failing embedding operation:
emb = nn.Embedding(num_embeddings=10, embedding_dim=100)

x = torch.tensor([0, 5, 9]) # valid indices as they are in [0, num_embeddings-1]
out = emb(x)

x = torch.tensor([0, 5, 10]) # invalid, since 10 is out of bounds
out = emb(x)
# > IndexError: index out of range in self