def run(self):
device = self.model_config.torch_device()<EOL>reinforcer = self.reinforcer.instantiate(device)<EOL>optimizer = self.optimizer_factory.instantiate(reinforcer.model)<EOL>callbacks = self.gather_callbacks(optimizer)<EOL>metrics = reinforcer.metrics()<EOL>training_info = self.resume_training(reinforcer, callbacks, metrics)<EOL>reinforcer.initialize_training(training_info)<EOL>training_info.on_train_begin()<EOL>if training_info.optimizer_initial_state:<EOL><INDENT>optimizer.load_state_dict(training_info.optimizer_initial_state)<EOL><DEDENT>global_epoch_idx = training_info.start_epoch_idx + <NUM_LIT:1><EOL>while training_info['<STR_LIT>'] < self.total_frames:<EOL><INDENT>epoch_info = EpochInfo(<EOL>training_info,<EOL>global_epoch_idx=global_epoch_idx,<EOL>batches_per_epoch=self.batches_per_epoch,<EOL>optimizer=optimizer,<EOL>)<EOL>reinforcer.train_epoch(epoch_info)<EOL>if self.openai_logging:<EOL><INDENT>self._openai_logging(epoch_info.result)<EOL><DEDENT>self.storage.checkpoint(epoch_info, reinforcer.model)<EOL>global_epoch_idx += <NUM_LIT:1><EOL><DEDENT>training_info.on_train_end()<EOL>return training_info<EOL>
Run reinforcement learning algorithm