code: def invert_dict(invertible_dict):
      
      inverted = {}
      for k, v in six.iteritems(invertible_dict):
          if not isinstance(v, Hashable):
              raise TypeError(u'Expected an invertible dict, but value at key {} has type {}'.format(
                  k, type(v).__name__))
          if v in inverted:
              raise TypeError(u'Expected an invertible dict, but keys '
                              u'{} and {} map to the same value'.format(
                                  inverted[v], k))
          inverted[v] = k
      return inverted
docs: Invert a dict. A dict is invertible if values are unique and hashable.