def EwkrwksT(k, r, s, d1, d2, ExxT, EggT, L):
    """
    Slower vesion of this function
    """
    K = L.shape[-1]
    N = ExxT.shape[0] // K
    D = L.shape[0]
    EgrgsT = EggT[r * N:(r + 1) * N, s * N:(s + 1) * N]
    wkrwksT = 0.0
    for i in range(K):
        for j in range(K):
            wkrwksT += ExxT[i * N:(i + 1) * N, j * N:(j + 1) * N] * L[d1, k, i
                ] * L[d2, k, j]
    return EgrgsT * wkrwksT
