code: def invert(d):
      """
      Invert a dictionary into a dictionary of sets.
  
      >>> invert({'a': 1, 'b': 2, 'c': 1})  # doctest: +SKIP
      {1: {'a', 'c'}, 2: {'b'}}
      """
      out = {}
      for k, v in iteritems(d):
          try:
              out[v].add(k)
          except KeyError:
              out[v] = {k}
      return out
  
file_path: zipline/zipline/utils/functional.py
imports: from functools import reduce
  from operator import itemgetter
  from pprint import pformat
  from six import viewkeys, iteritems
  from six.moves import map, zip
  from toolz import curry, flip
  from .sentinel import sentinel
label_desc: Use image node_id 11 for calling a global function with example usage: invert(d) and returns: out