code: def _invert_dictionary(self, d):
          
          inv_dict = {}
  
          for k, v in d.items():
              inv_dict[v] = inv_dict.get(v, [])
              inv_dict[v] += [k]
  
          return inv_dict
docs: Invert a dictionary.