def METHOD_NAME(k, alphas, betas):
    '''Function used to compute 
    generalization 2 (eq. 47 of 1902.08831 ). 
    second way to calculate generalized pg mixture, 
    based on iterative sum
    '''
    iters=[np.array(i) for i in bars_and_stars_iterator(int(k), len(betas))]
    log_res=[]
    for it in iters:
        log_res.append(calc_pg(it, alphas, betas).sum())
    return scipy.special.logsumexp(log_res)