@torch.no_grad()<EOL><INDENT>def rollout(self, batch_info: BatchInfo, model: RlModel, number_of_steps: int) -> Rollout:<DEDENT>
assert not model.is_recurrent, "<STR_LIT>"<EOL>accumulator = TensorAccumulator()<EOL>episode_information = []  <EOL>for step_idx in range(number_of_steps):<EOL><INDENT>step = model.step(self.last_observation)<EOL>replay_extra_information = {}<EOL>accumulator.add('<STR_LIT>', self.last_observation_cpu)<EOL>for name, tensor in step.items():<EOL><INDENT>tensor_cpu = tensor.cpu()<EOL>accumulator.add(name, tensor_cpu)<EOL>if name != '<STR_LIT>':<EOL><INDENT>replay_extra_information[name] = tensor_cpu.numpy()<EOL><DEDENT><DEDENT>actions_numpy = step['<STR_LIT>'].detach().cpu().numpy()<EOL>new_obs, new_rewards, new_dones, new_infos = self.environment.step(actions_numpy)<EOL>self.replay_buffer.store_transition(<EOL>frame=self.last_observation_cpu.numpy(),<EOL>action=actions_numpy,<EOL>reward=new_rewards,<EOL>done=new_dones,<EOL>extra_info=replay_extra_information<EOL>)<EOL>dones_tensor = torch.from_numpy(new_dones.astype(np.float32)).clone()<EOL>accumulator.add('<STR_LIT>', dones_tensor)<EOL>self.last_observation_cpu = torch.from_numpy(new_obs).clone()<EOL>self.last_observation = self.last_observation_cpu.to(self.device)<EOL>accumulator.add('<STR_LIT>', torch.from_numpy(new_rewards.astype(np.float32)).clone())<EOL>episode_information.append(new_infos)<EOL><DEDENT>accumulated_tensors = accumulator.result()<EOL>return Trajectories(<EOL>num_steps=accumulated_tensors['<STR_LIT>'].size(<NUM_LIT:0>),<EOL>num_envs=accumulated_tensors['<STR_LIT>'].size(<NUM_LIT:1>),<EOL>environment_information=episode_information,<EOL>transition_tensors=accumulated_tensors,<EOL>rollout_tensors={<EOL>'<STR_LIT>': model.value(self.last_observation).cpu()<EOL>}<EOL>)<EOL>
Calculate env rollout