def ijk_ljk_to_ilk(A, B):
res = np.zeros((A.shape[-<NUM_LIT:1>], A.shape[<NUM_LIT:0>], B.shape[<NUM_LIT:0>]))<EOL>[np.dot(A[:,:,i], B[:,:,i].T, out=res[i,:,:]) for i in range(A.shape[-<NUM_LIT:1>])]<EOL>res = res.swapaxes(<NUM_LIT:0>, <NUM_LIT:2>).swapaxes(<NUM_LIT:0>,<NUM_LIT:1>)<EOL>return res<EOL>
Faster version of einsum np.einsum('ijk,ljk->ilk', A, B)

I.e A.dot(B.T) for every dimension