code: def groupby(func, seq):
      """Group a collection by a key function
  
      >>> from sympy.multipledispatch.utils import groupby
      >>> names = ['Alice', 'Bob', 'Charlie', 'Dan', 'Edith', 'Frank']
      >>> groupby(len, names)  # doctest: +SKIP
      {3: ['Bob', 'Dan'], 5: ['Alice', 'Edith', 'Frank'], 7: ['Charlie']}
  
      >>> iseven = lambda x: x % 2 == 0
      >>> groupby(iseven, [1, 2, 3, 4, 5, 6, 7, 8])  # doctest: +SKIP
      {False: [1, 3, 5, 7], True: [2, 4, 6, 8]}
  
      See Also:
          ``countby``
      """
  
      d = {}
      for item in seq:
          key = func(item)
          if key not in d:
              d[key] = []
          d[key].append(item)
      return d
  
imports: from collections import OrderedDict
label_desc: Use image node_id 4 for calling a global function with example usage: groupby(func, seq) and returns: d