def spectral_penalty_d_optimal(svs, 
                               already_abs=False, 
                               already_normalized=False, 
                               eps=1e-7):
    """
    D-Optimal Regularizer as described in https://openreview.net/pdf?id=rJNH6sAqY7
    """
    svs = list(svs.values())
    if not already_abs:
        svs = [s.abs() for s in svs]
    if not already_normalized:
        svs = [s / s.max().clamp_min(eps) for s in svs]
    num_svs_total = sum(s.numel() for s in svs)
    reg = sum(-s.clamp_min(eps).log().sum() for s in svs)
    reg = reg / num_svs_total
    return reg