<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def calculate_energy(self, energies):
 """ Calculates the energy of the reaction. Args: energies ({Composition: float}):
 Energy for each composition. E.g ., {comp1: energy1, comp2: energy2}. Returns: reaction energy as a float. """

        return sum([amt * energies[c] for amt, c in zip(self._coeffs,
                                                        self._all_comp)])