code: def groupby(xs, key_fn):
      
      result = defaultdict(list)
      for x in xs:
          key = key_fn(x)
          result[key].append(x)
      return result
docs: Group elements of the list `xs` by keys generated from calling `key_fn`.
  
      Returns a dictionary which maps keys to sub-lists of `xs`.