hello, my neural network task I describe in these steps,

to extract as many patches I can from the image, currently I only consider square patches. (to make it more complicated, I could extract rectangular patches also, maybe in the future, there would be a way to extract non square/rectangular patch also).
for each of these patches, I also extract location
based on this location, I update the representation of each patch, that is if I extracted

[X] -> appears at index [0, 0]
[Y] -> appears at index [1, 1]
[XY
 YX] -> appears at index [5, 5] (consider the location of  first pixel for 2x2 patch)

then the first two patches would contribute to updating each others representation (I do a dot product between their embedding for this) as they are near, but the third patch is far from first two patches (how much far away patch I consider is a hyperparameter), so it would not contribute to the representation of first two patch (I would not take dot product of 3rd patch with 1st patch or 2nd patch)

I reduce the representation of the patch that represents the entire image to number of classes in my train set, and get a loss -> backprop -> optimize
after this all the patches that I have extracted from the image would have a learnt representation
during the test phase, when given a new image, then I again extract as many patches I can, along with location.
some of these patches would have a learnt representation, as they were found in training images, so my neural network has some idea, what does that pattern mean.
I once again apply step 3) for test image, and reduce representation of the patch that represents the entire image into number of classes -> get accuracy.

the part where I am stuck is, to how to extract location of each patch, and represent it in embedding, that is something like,
[X] -> appears at index [0, 0] -> represented by embedding1 of dim 10 (10 is a hyperparameter)
[XY
YX] -> appears at index [5, 5] -> represented by embedding2 of dim 10

plus I need to maintain the location, to do dot product, which information would be lost as soon as I represent a patch as an embedding.