def run(self):
device = self.model_config.torch_device()<EOL>learner = Learner(device, self.model_factory.instantiate())<EOL>callbacks = self.gather_callbacks()<EOL>metrics = learner.metrics()<EOL>training_info, hidden_state = self.resume_training(learner, callbacks, metrics)<EOL>current_phase_idx = self._select_phase_left_bound(training_info.start_epoch_idx)<EOL>current_phase = self.phases[current_phase_idx]<EOL>local_idx = training_info.start_epoch_idx - self.ladder[current_phase_idx]<EOL>current_phase.set_up_phase(training_info, learner.model, self.source)<EOL>print(current_phase.banner())<EOL>if training_info.start_epoch_idx > <NUM_LIT:0>:<EOL><INDENT>current_phase.restore(training_info, local_idx, learner.model, hidden_state)<EOL><DEDENT>training_info.on_train_begin()<EOL>for global_epoch_idx in range(training_info.start_epoch_idx + <NUM_LIT:1>, self.full_number_of_epochs + <NUM_LIT:1>):<EOL><INDENT>iteration_phase_idx = self._select_phase_right_bound(global_epoch_idx-<NUM_LIT:1>)<EOL>local_idx = global_epoch_idx - self.ladder[iteration_phase_idx]<EOL>while current_phase_idx != iteration_phase_idx:<EOL><INDENT>current_phase.tear_down_phase(training_info, learner.model)<EOL>current_phase_idx += <NUM_LIT:1><EOL>current_phase = self.phases[current_phase_idx]<EOL>current_phase.set_up_phase(training_info, learner.model, self.source)<EOL>print(current_phase.banner())<EOL><DEDENT>epoch_info = current_phase.epoch_info(training_info, global_epoch_idx, local_idx)<EOL>current_phase.execute_epoch(epoch_info, learner)<EOL>self.storage.checkpoint(epoch_info, learner.model)<EOL><DEDENT>if current_phase is not None:<EOL><INDENT>current_phase.tear_down_phase(training_info, learner.model)<EOL><DEDENT>training_info.on_train_end()<EOL>return training_info<EOL>
Run the command with supplied configuration