In the general case, an embedding is, indeed, a mapping from a N-d space to a M-d space. The simplest form of embedding is therefore a matrix A of shape (M,N) (but there are also non linear embeddings), such that the transformation is y = A * x.
However, in the field of Neural Machine Translation (NMT), the words/tokens are not represented by dense vectors like x = [0.556, 0.2465, 0.015, ...], but rather by one-hot encodings, like x = [0, 0, 0, 1, 0, 0, 0, ...]. Hence, they are uniquely identified by the index of the 1 in x.
Therefore, instead of doing a product A * x, you can lookup the row in A corresponding to the index, like y = A[x], which is more efficient.
That is exactly what nn.Embedding implements: it is a matrix which is used as a lookup table for the word indices.