<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def groupby(xs, key_fn):
 """ Group elements of the list `xs` by keys generated from calling `key_fn`. Returns a dictionary which maps keys to sub-lists of `xs`. """

    result = defaultdict(list)
    for x in xs:
        key = key_fn(x)
        result[key].append(x)
    return result