The nn.Embedding class is a lookup table mapping each index to a vector. In effect it is a matrix, the weight matrix of the embedding module.
Changing the vectors by a little bit will change the following computation by a small amount and eventually the (cross-entropy, typically) loss. Thus the vectors get a gradient in the backward step.
You could replace the nn.Embedding by a single parameter of dimension vocab_size * embedding_size and use indexing a[idxes] to get the vectors to get something that is mathematically equivalent, unless you use fancy features like inverse frequency scaling of gradients.
Best regards
Thomas