So I want to multiply 2 matrices that has dimensions:
torch.Size([10, 16, 240, 320])
torch.Size([10, 32, 240, 320])

now I want the output to be [10, 16, 32] (it will multiply the last 2 dimensions element-wise and sum them)
The code that generates the 2 metrics:
import torch

b = 10
h1 = 480
w1 = 640

h2 = 240
w2 = 320

m = 16
n = 32
# task 1: interpolate F1 [h1,w1] to [h2,w2] --> [h,w]
# task 2: multiply channel wise, sum them and divide by h*w, output-> [b,m,n]
F1 = torch.rand([b, m, h1, w1])
F2 = torch.rand([b, n, h2, w2])

F1 = torch.nn.functional.interpolate(F1, [h2, w2], mode = 'bicubic', align_corners = True)