all read into training i.e
input  one-hot tensor:     batch_size x seq_len
output embedding:  batch_size x seq_len x embedding_dim
it’s calculate in one time.
what’s the shape of input x, the code seems fine to me, more clear  to use:
x = x/ ((x.norm(dim=-1).view(-1,1).expand_as(x))