In the code batch size =128
embedding size is 256 (a word will be represented by a float tensor of size 256)
x is the max. length of caption in that batch of size 128
so,embeddings = self.embed(captions) will give you [128,x,256]
The feature vector the encoder output is of size [128,256]
features.unsqueeze(1) make it [128,1,256]
torch.cat around 1 will give you 128,x+1,256 so the embed size is not increased.