def _covcalc(a, b, wc):
    """
    Calculates the covariance from a * b^t
    :param a: The `a` matrix
    :type a: torch.Tensor
    :param b: The `b` matrix
    :type b: torch.Tensor
    :return: The covariance
    :rtype: torch.Tensor
    """
    cov = a.unsqueeze(-1) * b.unsqueeze(-2)

    return (wc[:, None, None] * cov).sum(-3)