diff --git a/parlai/core/metrics.py b/parlai/core/metrics.py index ec9f9fb11aa..75d510cb849 100644 --- a/parlai/core/metrics.py +++ b/parlai/core/metrics.py @@ -642,6 +642,16 @@ def clear(self): def share(self): return {'data': self._data} + def add_metrics(self, other: "Metrics") -> None: + """ + Aggregate another Metrics objects metrics into this one. + + Note that it is assumed that the keys for metrics are disjoint between Metrics + objects. + """ + for k, v in other._data.items(): + self.add(k, v) + class TeacherMetrics(Metrics): """