def feature_sampler(vec_f, auxiliary_sampler):
    """
    A generator function for tuples (F, log_q_xs, xs)

    Parameters
    ----------
    vec_f : function
        Pass `vec_f` as a (vectorized) function that operates on a vector of
        samples xs = {x1,...,xn} and returns a feature matrix (m x n), where m
        is some number of feature components.

    auxiliary_sampler : function
        Pass `auxiliary_sampler` as a function that returns a tuple
        (xs, log_q_xs) representing a sample to use for sampling (e.g.
        importance sampling) on the sample space of the model.

        xs : list, 1d ndarray, or 2d matrix (n x d)
            We require len(xs) == n.


    Yields
    ------
        tuples (F, log_q_xs, xs)

        F : matrix (m x n)
        log_q_xs : as returned by auxiliary_sampler
        xs : as returned by auxiliary_sampler

    """
    while True:
        xs, log_q_xs = auxiliary_sampler()
        F = vec_f(xs)
        yield F, log_q_xs, xs
