(codes_g,
                            codes_r,
                            n_subsets=50,
                            subset_size=1000,
                            **kernel_args)
return mmds
Computes average MMD between two set of features using n_subsets,
    each of which is of subset_size.

    Args:
        codes_g (ndarray): Set of features from 1st distribution.
        codes_r (ndarray): Set of features from 2nd distribution.
        n_subsets (int): Number of subsets to compute averages.
        subset_size (int): Size of each subset of features to choose.

    Returns:
        list: List of n_subsets MMD scores.
Computes average MMD between two set of features using n_subsets,
    each of which is of subset_size.
Computes average MMD between two set of features using n_subsets each of which is of subset_size .
def polynomial_mmd_averages(codes_g,
                            codes_r,
                            n_subsets=50,
                            subset_size=1000,
                            **kernel_args):
    """
    Computes average MMD between two set of features using n_subsets,
    each of which is of subset_size.

    Args:
        codes_g (ndarray): Set of features from 1st distribution.
        codes_r (ndarray): Set of features from 2nd distribution.
        n_subsets (int): Number of subsets to compute averages.
        subset_size (int): Size of each subset of features to choose.

    Returns:
        list: List of n_subsets MMD scores.
    """
    m = min(codes_g.shape[0], codes_r.shape[0])
    mmds = np.zeros(n_subsets)

    # Account for inordinately small subset sizes
    n_subsets = min(m, n_subsets)
    subset_size = min(subset_size, m // n_subsets)

    for i in range(n_subsets):
        g = codes_g[np.random.choice(len(codes_g), subset_size, replace=False)]
        r = codes_r[np.random.choice(len(codes_r), subset_size, replace=False)]
        o = polynomial_mmd(g, r, **kernel_args)
        mmds[i] = o

    return mmds
def polynomial_mmd_averages ( codes_g , codes_r , n_subsets = 50 , subset_size = 1000 , * * kernel_args ) : m = min ( codes_g . shape [ 0 ] , codes_r . shape [ 0 ] ) mmds = np . zeros ( n_subsets ) # Account for inordinately small subset sizes n_subsets = min ( m , n_subsets ) subset_size = min ( subset_size , m // n_subsets ) for i in range ( n_subsets ) : g = codes_g [ np . random . choice ( len ( codes_g ) , subset_size , replace = False ) ] r = codes_r [ np . random . choice ( len ( codes_r ) , subset_size , replace = False ) ] o = polynomial_mmd ( g , r , * * kernel_args ) mmds [ i ] = o return mmds