def transform_triples(triples, relation_types, entities):
	"""
	Groups a list of relations triples by their relations and returns a suitable data structure.

	Args:
		triples (list): List of relation triples as tuples.
		relation_types (dict): Dictionary with relations as key and the amount of triples with this relation as a key.
		entities (set): Set of unique entities.

	Returns:
		tuple: Dictionary with relation as key and a list of entity tuples as value and an augmented set of unique
			entities.
	"""
	grouped_triples = {key: [] for key in range(len(relation_types.keys()))}

	for triple in triples:
		entities.add(triple[0])
		entities.add(triple[2])
		grouped_triples[triple[1]].append((triple[0], triple[2]))

	return grouped_triples, entities