Contrastive loss on several features

I have k image inputs which I have the embeddings of each of them.
I wish to use a loss function (I was thinking of contrastive loss) on all of them so that they will be close to each other as possible

I was wondering how is it possible?