<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def remove_non_ground_states(self):
 """ Removes all non-ground state entries, i.e., only keep the lowest energy per atom entry at each composition. """

        group_func = lambda e: e.composition.reduced_formula
        entries = sorted(self.entries, key=group_func)
        ground_states = set()
        for _, g in itertools.groupby(entries, key=group_func):
            ground_states.add(min(g, key=lambda e: e.energy_per_atom))
        self.entries = ground_states