You would have to create a similarity matrix for all 140x140 images.
Based on the current similarity matrix it seems you are calculating it only on the current batch.
For 10 images, you would thus get a 10x10 matrix and for a single image you should get a single similarity score (image compared to itself).
To calculate the similarities between all images, you could use a nested loop with two DataLoaders.