class_docstr: Abstract base class for RLlib callbacks (similar to Keras callbacks).
  
  These callbacks can be used for custom metrics and custom postprocessing.
  
  By default, all of these callbacks are no-ops. To configure custom training
  callbacks, subclass DefaultCallbacks and then set
  {"callbacks": YourCallbacksClass} in the algo config.
class_docstr_tok: ["Abstract","base","class","for","RLlib","callbacks","(","similar","to","Keras","callbacks",")",".","These","callbacks","can","be","used","for","custom","metrics","and","custom","postprocessing",".","By","default",",","all","of","these","callbacks","are","no-ops",".","To","configure","custom","training","callbacks",",","subclass","DefaultCallbacks","and","then","set","{","``","callbacks","''",":","YourCallbacksClass","}","in","the","algo","config","."]
docstr: Called when an episode is done (after terminated/truncated have been logged).
  
  The exact time of the call of this callback is after `env.step([action])` and
  also after the results of this step (observation, reward, terminated, truncated,
  infos) have been logged to the given `episode` object, where either terminated
  or truncated were True.
  
  Note that on the new API stack, this callback is always preceeded by an
  `on_episode_step` call, which comes before the call to this method, but is
  provided with the non-finalized episode object (meaning the data has NOT
  been converted to numpy arrays yet).
  
  Args:
      episode: The terminated/truncated episode. On the new API stack, this will
          be a SingleAgentEpisode or MultiAgentEpisode object (which have already
          been finalized, meaning their data has been converted to numpy arrays).
          On the old API stack, this will be a Episode or EpisodeV2 object.
      env_runner: Replaces `worker` arg. Reference to the current EnvRunner.
      env: Replaces `base_env` arg.  The gym.Env (new API stack) or RLlib
          BaseEnv (old API stack) running the episode. On the old stack, the
          underlying sub environment objects can be retrieved by calling
          `base_env.get_sub_environments()`.
      rl_module: Replaces `policies` arg. Either the RLModule (new API stack) or a
          dict mapping policy IDs to policy objects (old stack). In single agent
          mode there will only be a single policy/RLModule under the
          `rl_module["default_policy"]` key.
      env_index: The index of the sub-environment that is about to be reset
          (within the vector of sub-environments of the BaseEnv).
      kwargs: Forward compatibility placeholder.
docstr_tok: ["Called","when","an","episode","is","done","(","after","terminated\/truncated","have","been","logged",")",".","The","exact","time","of","the","call","of","this","callback","is","after","`","env.step","(","[","action","]",")","`","and","also","after","the","results","of","this","step","(","observation",",","reward",",","terminated",",","truncated",",","infos",")","have","been","logged","to","the","given","`","episode","`","object",",","where","either","terminated","or","truncated","were","True",".","Note","that","on","the","new","API","stack",",","this","callback","is","always","preceeded","by","an","`","on_episode_step","`","call",",","which","comes","before","the","call","to","this","method",",","but","is","provided","with","the","non-finalized","episode","object","(","meaning","the","data","has","NOT","been","converted","to","numpy","arrays","yet",")",".","Args",":","episode",":","The","terminated\/truncated","episode",".","On","the","new","API","stack",",","this","will","be","a","SingleAgentEpisode","or","MultiAgentEpisode","object","(","which","have","already","been","finalized",",","meaning","their","data","has","been","converted","to","numpy","arrays",")",".","On","the","old","API","stack",",","this","will","be","a","Episode","or","EpisodeV2","object",".","env_runner",":","Replaces","`","worker","`","arg",".","Reference","to","the","current","EnvRunner",".","env",":","Replaces","`","base_env","`","arg",".","The","gym.Env","(","new","API","stack",")","or","RLlib","BaseEnv","(","old","API","stack",")","running","the","episode",".","On","the","old","stack",",","the","underlying","sub","environment","objects","can","be","retrieved","by","calling","`","base_env.get_sub_environments","(",")","`",".","rl_module",":","Replaces","`","policies","`","arg",".","Either","the","RLModule","(","new","API","stack",")","or","a","dict","mapping","policy","IDs","to","policy","objects","(","old","stack",")",".","In","single","agent","mode","there","will","only","be","a","single","policy\/RLModule","under","the","`","rl_module","[","``","default_policy","''","]","`","key",".","env_index",":","The","index","of","the","sub-environment","that","is","about","to","be","reset","(","within","the","vector","of","sub-environments","of","the","BaseEnv",")",".","kwargs",":","Forward","compatibility","placeholder","."]
code: def on_episode_end(
      self,
      *,
      # TODO (sven): Deprecate Episode/EpisodeV2 with new API stack.
      episode: Union[EpisodeType, Episode, EpisodeV2],
      # TODO (sven): Deprecate this arg new API stack (in favor of `env_runner`).
      worker: Optional["EnvRunner"] = None,
      env_runner: Optional["EnvRunner"] = None,
      # TODO (sven): Deprecate this arg new API stack (in favor of `env`).
      base_env: Optional[BaseEnv] = None,
      env: Optional[gym.Env] = None,
      # TODO (sven): Deprecate this arg new API stack (in favor of `rl_module`).
      policies: Optional[Dict[PolicyID, Policy]] = None,
      rl_module: Optional[RLModule] = None,
      env_index: int,
      **kwargs,
  ) -> None:
      """Called when an episode is done (after terminated/truncated have been logged).
  
      The exact time of the call of this callback is after `env.step([action])` and
      also after the results of this step (observation, reward, terminated, truncated,
      infos) have been logged to the given `episode` object, where either terminated
      or truncated were True.
  
      Note that on the new API stack, this callback is always preceeded by an
      `on_episode_step` call, which comes before the call to this method, but is
      provided with the non-finalized episode object (meaning the data has NOT
      been converted to numpy arrays yet).
  
      Args:
          episode: The terminated/truncated episode. On the new API stack, this will
              be a SingleAgentEpisode or MultiAgentEpisode object (which have already
              been finalized, meaning their data has been converted to numpy arrays).
              On the old API stack, this will be a Episode or EpisodeV2 object.
          env_runner: Replaces `worker` arg. Reference to the current EnvRunner.
          env: Replaces `base_env` arg.  The gym.Env (new API stack) or RLlib
              BaseEnv (old API stack) running the episode. On the old stack, the
              underlying sub environment objects can be retrieved by calling
              `base_env.get_sub_environments()`.
          rl_module: Replaces `policies` arg. Either the RLModule (new API stack) or a
              dict mapping policy IDs to policy objects (old stack). In single agent
              mode there will only be a single policy/RLModule under the
              `rl_module["default_policy"]` key.
          env_index: The index of the sub-environment that is about to be reset
              (within the vector of sub-environments of the BaseEnv).
          kwargs: Forward compatibility placeholder.
      """
      pass
  
imports: import gc
  import os
  import platform
  import tracemalloc
  from typing import TYPE_CHECKING, Dict, List, Optional, Tuple, Type, Union
  import gymnasium
  import numpy
  from ray.rllib.core.rl_module.rl_module import RLModule
  from ray.rllib.env.base_env import BaseEnv
  from ray.rllib.env.env_context import EnvContext
  from ray.rllib.evaluation.episode import Episode
  from ray.rllib.evaluation.episode_v2 import EpisodeV2
  from ray.rllib.evaluation.postprocessing import Postprocessing
  from ray.rllib.policy import Policy
  from ray.rllib.policy.sample_batch import SampleBatch
  from ray.rllib.utils.annotations import override, OverrideToImplementCustomLogic, PublicAPI
  from ray.rllib.utils.deprecation import deprecation_warning
  from ray.rllib.utils.exploration.random_encoder import _MovingMeanStd, compute_states_entropy, update_beta
  from ray.rllib.utils.typing import AgentID, EnvType, EpisodeType, PolicyID
  from ray.tune.callback import _CallbackMeta
  import psutil
label_desc: Use image node_id 11 for calling the DefaultCallbacks obj's underlying member method code with example usage: obj.on_episode_end() without return types