from functools import reduce
import operator


def make_count_cells_function(cache):
    """
    Return a function that computes the total number of cells
    across a list of image keys.

    """
    c = cache.get_cell_counts()
    return lambda image_keys: reduce(operator.add, (c.get(tuple(map(int, k)), 0) 
                                                    for k in image_keys))