Implement the branch of end_episode() entered during training.
190264
def _define_end_episode(self, agent_indices):
    """"""
    episodes, length = self._current_episodes.data(agent_indices)
    space_left = self._config.update_every - self._num_finished_episodes
    use_episodes = tf.range(tf.minimum(
        tf.shape(agent_indices)[0], space_left))
    episodes = tools.nested.map(lambda x: tf.gather(x, use_episodes), episodes)
    append = self._finished_episodes.replace(
        episodes, tf.gather(length, use_episodes),
        use_episodes + self._num_finished_episodes)
    with tf.control_dependencies([append]):
      increment_index = self._num_finished_episodes.assign_add(
          tf.shape(use_episodes)[0])
    with tf.control_dependencies([increment_index]):
      memory_full = self._num_finished_episodes >= self._config.update_every
      return tf.cond(memory_full, self._training, str)
73172
def on_epoch_end(self):
        
        self.freeze_epoch_result()

        for callback in self.callbacks:
            callback.on_epoch_end(self)

        self.training_info.history.add(self.result)
1235442
public void end() {
        if (TransitionConfig.isPrintDebug()) {
            getTransitionStateHolder().end();
            getTransitionStateHolder().print();
        }

        for (int i = 0, size = mTransitionControls.size(); i < size; i++) {
            mTransitionControls.get(i).end();
        }
    }
574637
def on_batch_end(self, last_target, train, **kwargs):
        ""
        if train: return
        bs = last_target.size(0)
        for name in self.names:
            self.metrics[name] += bs * self.learn.loss_func.metrics[name].detach().cpu()
        self.nums += bs
1271140
def bind_end(self, stream, future):
		""""""
		if not isinstance(stream, Stream):
			future.set_result(None)
		else:
			stream.pipe(TaskEndTransformer(future))
1269813
function finisher(error, output, callback)
{
  // signal end of the stream
  // only for successfully finished streams
  if (!error)
  {
    this.push(null);
  }

  // back to original track
  callback(error, output);
}
845174
def end(self):
        """"""
        # Close export modules
        for e in self._exports:
            self._exports[e].exit()
        # Close plugins
        for p in self._plugins:
            self._plugins[p].exit()
570454
def on_batch_end(self, train, **kwargs):
        ""
        if train: self.stats.append(self.hooks.stored)
339000
def finish(self):
        ''

        self.finished = True
        self.update(self.maxval)
        self.fd.write('\n')
        if self.signal_set:
            signal.signal(signal.SIGWINCH, signal.SIG_DFL)
15291
def _handle_end_relation(self):
        
        self._result.append(Relation(result=self._result, **self._curr))
        self._curr = {}
338228
def on_train_end(self, **kwargs: Any) -> None:  
        ""
        self.client.log_artifact(run_id=self.run, local_path=self.nb_path)
        self.client.set_terminated(run_id=self.run)
939438
def end_episode(self):
        
        self.training_buffer.reset_local_buffers()
        for agent_id in self.cumulative_rewards:
            self.cumulative_rewards[agent_id] = 0
        for agent_id in self.episode_steps:
            self.episode_steps[agent_id] = 0
        if self.use_curiosity:
            for agent_id in self.intrinsic_rewards:
                self.intrinsic_rewards[agent_id] = 0
784790
def set_end(self,t):
    
    self.__dur -= self.__end - t
    self.__end = t
1209957
def on_step_end(self, step, logs={}):
        
        self.total_steps += 1
        if self.total_steps % self.interval != 0:
            # Nothing to do.
            return

        filepath = self.filepath.format(step=self.total_steps, **logs)
        if self.verbose > 0:
            print('Step {}: saving model to {}'.format(self.total_steps, filepath))
        self.model.save_weights(filepath, overwrite=True)
758739
def step(self, action):
        """"""
        if self.done:
            raise ValueError("executing action in terminated episode")

        self.timestep += 1
        self._pre_action(action)
        end_time = self.cur_time + self.control_timestep
        while self.cur_time < end_time:
            self.sim.step()
            self.cur_time += self.model_timestep
        reward, done, info = self._post_action(action)
        return self._get_observation(), reward, done, info
857603
public function end()
    {
        // Already ended, skip
        if ($this->ended === true) {
            return;
        }

        if (function_exists('fastcgi_finish_request')) {
            fastcgi_finish_request();
        }

        $this->ended = true;

        $this->completeContext();
        $this->completeResponse();

        // We really want to avoid throwing exceptions there
        try {
            $this->log();
        } catch (Exception $e) {
            error_log($e->getMessage());
        }
    }
47399
def end(self):
        """"""
        TftpContext.end(self, not self.filelike_fileobj)
        self.metrics.end_time = time.time()
        log.debug("Set metrics.end_time to %s" % self.metrics.end_time)
        self.metrics.compute()