# Mutrix multiplication in tensor 4D

if i have `A=torch.rand(2,3,5,6)` and `B = torch.rand(2,3,6,7)` how I can do multiplication in a way that my output `C` has `2x3x5x7` dimension. in other words, i do matrix multiplication in a way that

``````C[0,0,:,:] = A[0,0,:,:]xB[0,0,:,:]
C[0,1,:,:] = A[0,1,:,:]xB[0,1,:,:]
C[0,2,:,:] = A[0,0,:,:]xB[0,2,:,:]
C[1,0,:,:] = A[1,0,:,:]xB[1,0,:,:]
C[1,1,:,:] = A[1,1,:,:]xB[1,1,:,:]
C[1,2,:,:] = A[1,2,:,:]xB[1,2,:,:]
....
``````

I think einsum could be used here

``````x = torch.randn(2, 3, 5, 6)
y = torch.randn(2, 3, 6, 7)
z = torch.einsum('abcd, abde -> abce', x, y)
z.shape
``````