Removing api.aggregate_losses means keeping all the outputs in memory. This is exactly what we wanted to avoid.