I do some more work on this, I share till where I reach, consider our input image to be, 3x3, with 3 variety of pixels, 0, 1, and 2.
image = torch.tensor([[0., 1., 2.],
                      [0., 2., 1.],
                      [0., 0., 0.]])

I extract location of each pixel, it look something like this,
location = torch.tensor([[[0., 0., 0., 0.], [0., 0., 0., 1.], [0., 0., 1., 0.]],
                         [[0., 1., 0., 0.], [0., 1., 0., 1.], [0., 1., 1., 0.]],
                         [[1., 0., 0., 0.], [1., 0., 0., 1.], [1., 0., 1., 0.]]])

first 2 bits row, last 2 bits column
get an embedded_image_with_location,
tensor([[[0, 0, 0, 0, 0, 0],
         [0, 1, 0, 0, 0, 1],
         [1, 0, 0, 0, 1, 0]],

        [[0, 0, 0, 1, 0, 0],
         [1, 0, 0, 1, 0, 1],
         [0, 1, 0, 1, 1, 0]],

        [[0, 0, 1, 0, 0, 0],
         [0, 0, 1, 0, 0, 1],
         [0, 0, 1, 0, 1, 0]]], dtype=torch.int32)

first two bit indicate pixel, last four bit indicate location
next, i create a pattern extractor, suppose it extract 5 patterns from our input image,
(how many patterns do it extract, and what all patterns do it extract be a confusion, for example, when we see a human face, then we extract patterns like, eye, nose, ear, hair, and so on)
[tensor([[0, 0, 0, 0, 0, 0],
         [0, 1, 0, 0, 0, 1],
         [1, 0, 0, 0, 1, 0],
         [1, 0, 0, 1, 0, 1],
         [0, 0, 1, 0, 0, 0],
         [0, 0, 1, 0, 0, 1]], dtype=torch.int32),
 tensor([[0, 0, 0, 1, 0, 0]], dtype=torch.int32),
 tensor([[0, 0, 0, 0, 0, 0],
         [0, 1, 0, 0, 0, 1],
         [0, 0, 1, 0, 0, 0]], dtype=torch.int32),
 tensor([[0, 1, 0, 0, 0, 1]], dtype=torch.int32),
 tensor([[0, 0, 1, 0, 0, 0]], dtype=torch.int32)]

next, I create a link dictionary, that work something like this, (for example, ear be part of face, pupil be part of eye, and so on)
defaultdict(list, {0: [5], 1: [5], 2: [0, 5], 3: [0, 2, 5], 4: [0, 2, 5]})

here, 5 represent entire image,
0 be a part of 5
2 be a part of 0 and 5, and so on.
now, the task of our neural network be to update this link dictionary, if told that this image belong to class lets say 7, then the updated link dictionary look like, (if the image was of a human face, then 7 represent human face, and the image be linked to this class, the class be linked to this image)
defaultdict(list, {0: [5], 1: [5], 2: [0, 5], 3: [0, 2, 5], 4: [0, 2, 5], 5: [7], 7: [5]})

there be a 2 way link between 5 and 7.
when shown a variation of the same image, then we again, extract patterns from the image, search within the link dictionary for a pattern, that be in training image, and test image, (for example, if in the test set, there is a variation of a human face, then it extract pattern, and search for pattern in the link dictionary) and the closest class that we get (that be minimum number of links away) be the prediction.
I do not know what be parameter in this case, and what be the way to extract patterns from input image.