Solved by jmandivarapu1 in post #2 
              
              
                I can’t exact solution but in general in pytorch with Matrices M1 and M2 you can do like this 
Hope it helps a bit 
#M1(n x a) with M2(a x b x c) to get M3(n x b x c)
torch.mm(M1, M2.view(a, -1)).view(n, b, c)

# Matrix x Matrix
# Size 2x4
mat1 = torch.randn(2, 3)
mat2 = torch.randn(3, 4)
r = torch.…