<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def average(a, b, distance_function):
 """ Given two collections ``a`` and ``b``, this will return the mean of all distances. ``distance_function`` is used to determine the distance between two elements. Example:: 26 """

    distances = [distance_function(x, y)
                 for x in a for y in b]
    return sum(distances) / len(distances)