def _fetch_atari_metrics(base_env): """Atari games have multiple logical episodes, one per life. However for metrics reporting we count full episodes all lives included. """ unwrapped = base_env.get_unwrapped() if not unwrapped: return None atari_out = [] for u in unwrapped: monitor = get_wrapper_by_cls(u, MonitorEnv) if not monitor: return None for eps_rew, eps_len in monitor.next_episode_results(): atari_out.append(RolloutMetrics(eps_len, eps_rew, {}, {})) return atari_out