Actually, It seems I asked my question ambiguously.
By A @ A.T, I mean the definition of Gram matrix which is multiplication of a matrix to its transpose, not a numpy code. My question was why do we have to reshape matrices.Now, I can understand that the only way to multiply two 4-D matrices is to reshape them into 2-D matrices then multiply them (the .t() function only works on 2-D matrix, obviously).
Based on tutorial, batch_size and channel_size has been considered as number of feature maps and height and width of images as length of any vectorized feature map
Now, in my problem, I have a 5-D matrix with a dimesion called patch_size and I considered it as number of feature maps that only can cause a difference in output matrix size, but not the values, so I think it will not cause any problem in computing loss process.
Thanks for help