docstr: Make any changes needed when each episode is ended.
  This includes incrementing counters, updating full episode dependent values, updating logs, etc.
  This function is called right after each episode is ended.
  
  :return: None
docstr_tok: ["Make","any","changes","needed","when","each","episode","is","ended",".","This","includes","incrementing","counters",",","updating","full","episode","dependent","values",",","updating","logs",",","etc",".","This","function","is","called","right","after","each","episode","is","ended",".",":","return",":","None"]
code: def handle_episode_ended(self) -> None:
      """
      Make any changes needed when each episode is ended.
      This includes incrementing counters, updating full episode dependent values, updating logs, etc.
      This function is called right after each episode is ended.
  
      :return: None
      """
      self.current_episode_buffer.is_complete = True
      self.current_episode_buffer.update_transitions_rewards_and_bootstrap_data()
  
      for transition in self.current_episode_buffer.transitions:
          self.discounted_return.add_sample(
              transition.n_step_discounted_rewards
          )
  
      if (
          self.phase != RunPhase.TEST
          or self.ap.task_parameters.evaluate_only is not None
      ):
          self.current_episode += 1
  
      if self.phase != RunPhase.TEST:
          if isinstance(self.memory, EpisodicExperienceReplay):
              if (
                  self.ap.algorithm.override_episode_rewards_with_the_last_transition_reward
              ):
                  for t in self.current_episode_buffer.transitions:
                      t.reward = (
                          self.current_episode_buffer.transitions[
                              -1
                          ].reward
                      )
              self.call_memory(
                  "store_episode", self.current_episode_buffer
              )
          elif (
              self.ap.algorithm.store_transitions_only_when_episodes_are_terminated
          ):
              for transition in self.current_episode_buffer.transitions:
                  self.call_memory("store", transition)
  
      if self.phase == RunPhase.TEST:
          self.accumulated_rewards_across_evaluation_episodes += (
              self.total_reward_in_current_episode
          )
          self.accumulated_shaped_rewards_across_evaluation_episodes += (
              self.total_shaped_reward_in_current_episode
          )
          self.num_evaluation_episodes_completed += 1
  
          if (
              self.spaces.reward.reward_success_threshold
              and self.total_reward_in_current_episode
              >= self.spaces.reward.reward_success_threshold
          ):
              self.num_successes_across_evaluation_episodes += 1
  
      if (
          self.ap.visualization.dump_csv
          and self.parent_level_manager.parent_graph_manager.time_metric
          == TimeTypes.EpisodeNumber
      ):
          self.update_log()
  
      # TODO verbosity was mistakenly removed from task_parameters on release 0.11.0, need to bring it back
      # if self.ap.is_a_highest_level_agent or self.ap.task_parameters.verbosity == "high":
      if self.ap.is_a_highest_level_agent:
          self.log_to_screen()
  
imports: import copy
  import random
  from collections import OrderedDict
  from typing import Dict, List, Union, Tuple
  import numpy
  from six.moves import range
  from rl_coach.agents.agent_interface import AgentInterface
  from rl_coach.architectures.network_wrapper import NetworkWrapper
  from rl_coach.base_parameters import AgentParameters, Device, DeviceType, DistributedTaskParameters, Frameworks
  from rl_coach.core_types import RunPhase, PredictionType, EnvironmentEpisodes, ActionType, Batch, Episode, StateType
  from rl_coach.core_types import Transition, ActionInfo, TrainingSteps, EnvironmentSteps, EnvResponse
  from rl_coach.logger import screen, Logger, EpisodeLogger
  from rl_coach.memories.episodic.episodic_experience_replay import EpisodicExperienceReplay
  from rl_coach.saver import SaverCollection
  from rl_coach.spaces import SpacesDefinition, VectorObservationSpace, GoalsSpace, AttentionActionSpace
  from rl_coach.utils import Signal, force_list
  from rl_coach.utils import dynamic_import_and_instantiate_module_from_params
  from rl_coach.memories.backend.memory_impl import get_memory_backend
  from rl_coach.core_types import TimeTypes
  from rl_coach.off_policy_evaluators.ope_manager import OpeManager
  from rl_coach.core_types import PickledReplayBuffer, CsvDataset
label_desc: Use image node_id 19 for calling the Agent obj's underlying member method code with example usage: obj.handle_episode_ended() without return types