The typo was in my code, not here. It was like
b, n, c, h, w = data1.size()
data1 = data1.view(b*n, c, h, w)
.
.
.
data2 = data2.view(b*n, c, h, w) # forgot to get size of data2 but used size of data1

lol