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 the agent-environment interaction loop for specified number of steps
  and episodes.
  
  :param env: Environment to run.
  :param agent: Agent to use.
  :param n_episodes: Count of episodes to perform.
  :param env_seeds: The env seeds to be used for each episode.
  :param agent_seeds: The agent seeds to be used for each episode.
  :param render: Whether to render the environment after every step.
  :param after_reset_callback: If supplied, this will be executed after each episode to notify the observer.
docstr_tok: ["Helper","function","for","running","the","agent-environment","interaction","loop","for","specified","number","of","steps","and","episodes",".",":","param","env",":","Environment","to","run",".",":","param","agent",":","Agent","to","use",".",":","param","n_episodes",":","Count","of","episodes","to","perform",".",":","param","env_seeds",":","The","env","seeds","to","be","used","for","each","episode",".",":","param","agent_seeds",":","The","agent","seeds","to","be","used","for","each","episode",".",":","param","render",":","Whether","to","render","the","environment","after","every","step",".",":","param","after_reset_callback",":","If","supplied",",","this","will","be","executed","after","each","episode","to","notify","the","observer","."]
code: def run_interaction_loop(
      cls,
      env: StructuredEnv,
      agent: Policy,
      n_episodes: int,
      env_seeds: List[Any],
      agent_seeds: List[Any],
      deterministic: bool,
      render: bool = False,
      after_reset_callback: Callable = None,
  ) -> None:
      """Helper function for running the agent-environment interaction loop for specified number of steps
      and episodes.
  
      :param env: Environment to run.
      :param agent: Agent to use.
      :param n_episodes: Count of episodes to perform.
      :param env_seeds: The env seeds to be used for each episode.
      :param agent_seeds: The agent seeds to be used for each episode.
      :param render: Whether to render the environment after every step.
      :param after_reset_callback: If supplied, this will be executed after each episode to notify the observer.
      """
  
      for idx in range(n_episodes):
          env_seed, agent_seed = env_seeds[idx], agent_seeds[idx]
          env.seed(env_seed)
          agent.seed(agent_seed)
          try:
              obs = env.reset()
              agent.reset()
          except Exception as exception:
              BColors.print_colored(
                  f"A error was encountered during reset on the env_seed: {env_seed} with "
                  f"agent_seed: {agent_seed}",
                  BColors.FAIL,
              )
              raise exception
  
          if idx > 0:
              after_reset_callback()
  
          try:
              cls.run_episode(
                  env=env,
                  obs=obs,
                  agent=agent,
                  deterministic=deterministic,
                  render=render,
              )
          except Exception as exception:
              BColors.print_colored(
                  f"A error was encountered during rollout on the env_seed: {env_seed} with "
                  f"agent_seed: {agent_seed}",
                  BColors.FAIL,
              )
              raise exception
  
      # Reset env and agent at the very end in order to collect the statistics
      env.reset()
      agent.reset()
      if after_reset_callback is not None:
          after_reset_callback()
  
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 7 for calling the RolloutRunner obj's underlying member method code with example usage: obj.run_interaction_loop(cls, env, agent, n_episodes, env_seeds, agent_seeds, deterministic, render, after_reset_callback) without return types