(dists, f, batch_size, device)
Returns an infinite generator that runs through randomized z
    batches, forever.
Returns an infinite generator that runs through randomized z
    batches, forever.
Returns an infinite generator that runs through randomized z batches forever .
def infinite_sampler(dists, f, batch_size, device):
    '''
    Returns an infinite generator that runs through randomized z
    batches, forever.
    '''
    while True:
        zs = [dist.sample([batch_size]).to(device) for dist in dists]
        r = zs[0] if f is None else f(*zs)
        yield (r,)
def infinite_sampler ( dists , f , batch_size , device ) : while True : zs = [ dist . sample ( [ batch_size ] ) . to ( device ) for dist in dists ] r = zs [ 0 ] if f is None else f ( * zs ) yield ( r , )