from functools import reduce


def run_map(generator, mapper) -> list:
    """
    Map function caller for each line in each file
    :param generator: file and line generator
    :param mapper: map function to be called for each line in the files
    :return: generator of key value pairs returned by the map function
    """
    return reduce(lambda x, y: x + y,
                  map(lambda kv_file_lines:
                      reduce(lambda x, y: x + y,
                             map(lambda line:
                                 list(mapper(kv_file_lines[0], line)),
                                 kv_file_lines[1])),
                      generator))