class_docstr: The generic environment runner for the single agent case.
class_docstr_tok: ["The","generic","environment","runner","for","the","single","agent","case","."]
code: def _make_on_episode_callback(
      self, which: str, idx: int, episodes=None
  ):
      episodes = episodes if episodes is not None else self._episodes
      getattr(self._callbacks, which)(
          episode=episodes[idx],
          env_runner=self,
          env=self.env,
          rl_module=self.module,
          env_index=idx,
      )
  
imports: import gymnasium
  import numpy
  import tree
  from collections import defaultdict
  from functools import partial
  from typing import Dict, List, Optional
  from ray.rllib.algorithms.algorithm_config import AlgorithmConfig
  from ray.rllib.algorithms.callbacks import DefaultCallbacks
  from ray.rllib.core.rl_module.rl_module import RLModule, SingleAgentRLModuleSpec
  from ray.rllib.env.env_runner import EnvRunner
  from ray.rllib.env.single_agent_episode import SingleAgentEpisode
  from ray.rllib.env.utils import _gym_env_creator
  from ray.rllib.evaluation.metrics import RolloutMetrics
  from ray.rllib.policy.sample_batch import DEFAULT_POLICY_ID, SampleBatch
  from ray.rllib.utils.annotations import ExperimentalAPI, override
  from ray.rllib.utils.framework import try_import_tf, try_import_torch
  from ray.rllib.utils.torch_utils import convert_to_torch_tensor
  from ray.rllib.utils.typing import TensorType
  from ray.tune.registry import ENV_CREATOR, _global_registry
label_desc: Use image node_id 5 for calling the SingleAgentEnvRunner obj's underlying member method code with example usage: obj._make_on_episode_callback(which, idx, episodes) without return types