def invert_mapping(mapping):
 invert_map = {}
 for key in mapping.keys():
  invert_map[key] = key
  for id in mapping[key]:
   invert_map[id] = key
 return invert_map

def invert_mapping ( mapping ) : invert_map = { } for key in mapping . keys ( ) : invert_map [ key ] = key for id in mapping [ key ] : invert_map [ id ] = key return invert_map
inverts a dictionary mapping .