def iter_to_generator(iterator):
    """Gets a generator from an iterator.

    Used so that keras type checking does not complain.

    Args:
        iterator: any python iterator

    Returns:
        a python generator that just calls next on the iterator
    """

    def gen():
        while True:
            yield next(iterator)

    return gen()