Faster version of einsum np.einsum('ijk,ljk->ilk', A, B)

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

def ijk_ljk_to_ilk(A, B):
    """
    Faster version of einsum np.einsum('ijk,ljk->ilk', A, B)

    I.e A.dot(B.T) for every dimension
    """
    res = np.zeros((A.shape[-1], A.shape[0], B.shape[0]))
    [np.dot(A[:,:,i], B[:,:,i].T, out=res[i,:,:]) for i in range(A.shape[-1])]
    res = res.swapaxes(0, 2).swapaxes(0,1)
    return res