Appending to an Embedding

I have an nn.Embedding of dimension 5, let’s say x = (x1,x2…x5) now I would like to apply a function on it such that each embedding becomes one with dimensions=6 with new embedding tensor x’ = (2||x||, x1,x2,x3…x5), ||x|| is the norm of the original tensor. Is there a way to do this?

Thank You.

Yes you just need to concatenate them - https://pytorch.org/docs/stable/torch.html#torch.cat