code: def apply_groupby(records, fn, skip_none=False):
      
  
      # create an empty list for every new key
      groups = defaultdict(list)
      for record in records:
          value = fn(record)
          if value is not None or not skip_none:
              groups[value].append(record)
      return dict(groups)
docs: Given a list of objects, group them into a dictionary by
      applying fn to each one and using returned values as a dictionary
      key.
  
      Parameters
      ----------
      records : list
  
      fn : function
  
      skip_none : bool
          If False, then None can be a key in the returned dictionary,
          otherwise records whose key value is None get skipped.
  
      Returns dict.