class_docstr: General abstract class for rollout runners.
  
  Offers general structure, plus a couple of helper methods for env instantiation and performing the rollout.
  
  :param n_episodes: Count of episodes to run. If explicit seeds are given the actual number of episodes is given by
                     min(n_episodes, n_seeds).
  :param max_episode_steps: Count of steps to run in each episode (if environment returns done, the episode
                            will be finished earlier though).
  :param deterministic: Deterministic or stochastic action sampling.
  :param record_trajectory: Whether to record trajectory data.
  :param record_event_logs: Whether to record event logs.
class_docstr_tok: ["General","abstract","class","for","rollout","runners",".","Offers","general","structure",",","plus","a","couple","of","helper","methods","for","env","instantiation","and","performing","the","rollout",".",":","param","n_episodes",":","Count","of","episodes","to","run",".","If","explicit","seeds","are","given","the","actual","number","of","episodes","is","given","by","min","(","n_episodes",",","n_seeds",")",".",":","param","max_episode_steps",":","Count","of","steps","to","run","in","each","episode","(","if","environment","returns","done",",","the","episode","will","be","finished","earlier","though",")",".",":","param","deterministic",":","Deterministic","or","stochastic","action","sampling",".",":","param","record_trajectory",":","Whether","to","record","trajectory","data",".",":","param","record_event_logs",":","Whether","to","record","event","logs","."]
docstr: Helper function for running a single episode.
  
  :param env: Environment to run.
  :param obs: Initial observation, as returned by reset().
  :param deterministic: Argmax policy.
  :param agent: Agent to use.
  :param render: Whether to render the environment after every step.
docstr_tok: ["Helper","function","for","running","a","single","episode",".",":","param","env",":","Environment","to","run",".",":","param","obs",":","Initial","observation",",","as","returned","by","reset","(",")",".",":","param","deterministic",":","Argmax","policy",".",":","param","agent",":","Agent","to","use",".",":","param","render",":","Whether","to","render","the","environment","after","every","step","."]
code: def run_episode(
      env: StructuredEnv,
      obs: ObservationType,
      agent: Policy,
      deterministic: bool,
      render: bool,
  ) -> None:
      """Helper function for running a single episode.
  
      :param env: Environment to run.
      :param obs: Initial observation, as returned by reset().
      :param deterministic: Argmax policy.
      :param agent: Agent to use.
      :param render: Whether to render the environment after every step.
      """
  
      done = False
      while not done:
          # inject the MazeEnv state if desired by the policy
          action = agent.compute_action(
              observation=obs,
              actor_id=env.actor_id(),
              maze_state=env.get_maze_state()
              if agent.needs_state()
              else None,
              env=env if agent.needs_env() else None,
              deterministic=deterministic,
          )
  
          obs, rew, done, info = env.step(action)
  
          if render:
              assert isinstance(env, TrajectoryRecordingWrapper), (
                  "Rendering is supported only when "
                  "trajectory recording is enabled."
              )
              env.render()
  
imports: import time
  from abc import ABC, abstractmethod
  from typing import Callable, Optional, List, Any
  import numpy
  from omegaconf import DictConfig
  from maze.core.agent.policy import Policy
  from maze.core.annotations import override
  from maze.core.env.maze_env import MazeEnv
  from maze.core.env.observation_conversion import ObservationType
  from maze.core.env.structured_env import StructuredEnv
  from maze.core.utils.config_utils import EnvFactory, SwitchWorkingDirectoryToInput
  from maze.core.utils.factory import Factory, ConfigType, CollectionOfConfigType
  from maze.core.utils.seeding import MazeSeeding
  from maze.core.wrappers.time_limit_wrapper import TimeLimitWrapper
  from maze.core.wrappers.trajectory_recording_wrapper import TrajectoryRecordingWrapper
  from maze.runner import Runner
  from maze.utils.bcolors import BColors
label_desc: Use image node_id 6 for calling the RolloutRunner obj's underlying member method code with example usage: obj.run_episode(env, obs, agent, deterministic, render) without return types