import tensorflow as tf

    if y is None:
        y = silverman_rule_of_thumb(N)

    K = 1/(2*D-3)

    A1 = euclidean_norm_squared(tf.subtract(tf.expand_dims(X, 0), tf.expand_dims(X, 1)), axis=2)
    A = (1/(N**2)) * tf.reduce_sum((1/tf.sqrt(y + K*A1)))

    B1 = euclidean_norm_squared(X, axis=1)
    B = (2/N)*tf.reduce_sum((1/tf.sqrt(y + 0.5 + K*B1)))

    return (1/tf.sqrt(1+y)) + A - B


def cw_choose(z_dim: int):
    if z_dim == 1:
        return cw_1d
    elif z_dim == 2:
        return cw_2d
    elif z_dim >= 20:
        return cw
    else:
