def invoke(self):
self._counter += <NUM_LIT:1><EOL>if self._counter % self._freq == <NUM_LIT:0>:<EOL><INDENT>cnt = <NUM_LIT:0.><EOL>sum_map = defaultdict(float)<EOL>for x in self._trainer.get_data(self._data_split):<EOL><INDENT>val_map = self.run(x)<EOL>if not isinstance(val_map, dict):<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>for k, val in val_map.items():<EOL><INDENT>sum_map[k] += val<EOL><DEDENT>cnt += <NUM_LIT:1><EOL><DEDENT>for k in sum_map:<EOL><INDENT>sum_map[k] /= cnt<EOL><DEDENT>new_best = self.compare(sum_map)<EOL>self._trainer.report(sum_map, self._data_split, new_best=new_best)<EOL>if new_best:<EOL><INDENT>self._trainer.save_checkpoint(self._save_path)<EOL><DEDENT><DEDENT>
This function will be called after each iteration.