def renyi(alphas, Ks, dim, required, min_val=np.spacing(<NUM_LIT:1>),<EOL>clamp=True, to_self=False):
alphas = np.reshape(alphas, (-<NUM_LIT:1>, <NUM_LIT:1>))<EOL>est = required<EOL>est = np.maximum(est, min_val)  <EOL>np.log(est, out=est)<EOL>est /= alphas - <NUM_LIT:1><EOL>if clamp:<EOL><INDENT>np.maximum(est, <NUM_LIT:0>, out=est)<EOL><DEDENT>return est<EOL>
r'''
    Estimate the Renyi-alpha divergence between distributions, based on kNN
    distances:  1/(\alpha-1) \log \int p^alpha q^(1-\alpha)

    If the inner integral is less than min_val (default ``np.spacing(1)``),
    uses the log of min_val instead.

    If clamp (the default), enforces that the estimates are nonnegative by
    replacing any negative estimates with 0.

    Returns an array of shape (num_alphas, num_Ks).