human
Solve the following python programming problem given the following code:
@contextlib.contextmanager
def multimap(cores=None):
assistant
#Here is the Python code you requested.

    """Provide multiprocessing imap like function.
    The context manager handles setting up the pool, worked around interrupt issues
    and terminating the pool on completion.
    """
    if (cores is None):
        cores = max((multiprocessing.cpu_count() - 1), 1)
    def wrapper(func):
        def wrap(self, timeout=None):
            return func(self, timeout=(timeout if (timeout is not None) else 1e+100))
        return wrap
    IMapIterator.next = wrapper(IMapIterator.next)
    pool = multiprocessing.Pool(cores)
    (yield pool.imap)
    pool.terminate()