code: def partition_to_color(partitions):
      """
      Creates a dictionary that maps each item in each partition to the index of
      the partition to which it belongs.
  
      Parameters
      ----------
      partitions: collections.abc.Sequence[collections.abc.Iterable]
          As returned by :func:`make_partitions`.
  
      Returns
      -------
      dict
      """
      colors = {}
      for color, keys in enumerate(partitions):
          for key in keys:
              colors[key] = color
      return colors
  
imports: import itertools
  from collections import Counter, defaultdict
  from functools import reduce, wraps
label_desc: Use image node_id 3 for calling a global function with example usage: partition_to_color(partitions) and returns: colors