code: def _inv_dict(d):
      """Reverse a dictionary mapping.
  
      Returns multimap where the keys are the former values,
      and values are sets of the former keys.
  
      Args:
          d (dict[a->b]): mapping to reverse
  
      Returns:
          dict[b->set[a]]: reversed mapping
      """
      ret = {}
      for k, v in d.items():
          ret.setdefault(v, set()).add(k)
      return ret
  
file_path: pennylane/pennylane/utils.py
imports: from collections.abc import Iterable
  import functools
  import inspect
  import numbers
  import numpy
  import pennylane
label_desc: Use image node_id 4 for calling a global function with example usage: _inv_dict(d) and returns: ret