class_docstr: Class encapsulating functionality performed in worker processes.
class_docstr_tok: ["Class","encapsulating","functionality","performed","in","worker","processes","."]
docstr: Build the environment and run the rollout for the specified number of episodes.
  
  :param env_config: Hydra configuration of the environment to instantiate.
  :param wrapper_config: Hydra configuration of environment wrappers.
  :param agent_config: Hydra configuration of agent's policies.
  :param deterministic: Deterministic or stochastic action sampling.
  :param max_episode_steps: Max number of steps per episode to perform
                              (episode might end earlier if env returns done).
  :param record_trajectory: Whether to record trajectory data.
  :param input_directory: Directory to load the model from.
  :param reporting_queue: Queue for passing the stats and event logs back to the main process after each episode.
  :param seeding_queue: Queue for retrieving seeds.
docstr_tok: ["Build","the","environment","and","run","the","rollout","for","the","specified","number","of","episodes",".",":","param","env_config",":","Hydra","configuration","of","the","environment","to","instantiate",".",":","param","wrapper_config",":","Hydra","configuration","of","environment","wrappers",".",":","param","agent_config",":","Hydra","configuration","of","agent","'s","policies",".",":","param","deterministic",":","Deterministic","or","stochastic","action","sampling",".",":","param","max_episode_steps",":","Max","number","of","steps","per","episode","to","perform","(","episode","might","end","earlier","if","env","returns","done",")",".",":","param","record_trajectory",":","Whether","to","record","trajectory","data",".",":","param","input_directory",":","Directory","to","load","the","model","from",".",":","param","reporting_queue",":","Queue","for","passing","the","stats","and","event","logs","back","to","the","main","process","after","each","episode",".",":","param","seeding_queue",":","Queue","for","retrieving","seeds","."]
code: def run(
      env_config: DictConfig,
      wrapper_config: DictConfig,
      agent_config: DictConfig,
      deterministic: bool,
      max_episode_steps: int,
      record_trajectory: bool,
      input_directory: str,
      reporting_queue: Queue,
      seeding_queue: Queue,
  ) -> None:
      """Build the environment and run the rollout for the specified number of episodes.
  
      :param env_config: Hydra configuration of the environment to instantiate.
      :param wrapper_config: Hydra configuration of environment wrappers.
      :param agent_config: Hydra configuration of agent's policies.
      :param deterministic: Deterministic or stochastic action sampling.
      :param max_episode_steps: Max number of steps per episode to perform
                                  (episode might end earlier if env returns done).
      :param record_trajectory: Whether to record trajectory data.
      :param input_directory: Directory to load the model from.
      :param reporting_queue: Queue for passing the stats and event logs back to the main process after each episode.
      :param seeding_queue: Queue for retrieving seeds.
      """
      if seeding_queue.empty():
          return
  
      env_seed, agent_seed = None, None
      try:
          env, agent = RolloutRunner.init_env_and_agent(
              env_config,
              wrapper_config,
              max_episode_steps,
              agent_config,
              input_directory,
          )
          (
              env,
              episode_recorder,
          ) = ParallelRolloutWorker._setup_monitoring(
              env, record_trajectory
          )
  
          first_episode = True
          while True:
              try:
                  env_seed, agent_seed = seeding_queue.get(block=False)
              except Empty:
                  # after we finished the last seed, we need to reset env and agent to collect the
                  # statistics of the last rollout
                  try:
                      env.reset()
                      agent.reset()
                  except Exception as e:
                      logger.warning(
                          "Exception encountered in collection reset()"
                      )
                      ParallelRolloutWorker._log_exception(e)
  
                  reporting_queue.put(
                      episode_recorder.get_last_episode_data()
                  )
  
                  return
  
              env.seed(env_seed)
              agent.seed(agent_seed)
              try:
                  obs = env.reset()
                  agent.reset()
  
                  RolloutRunner.run_episode(
                      env=env,
                      agent=agent,
                      obs=obs,
                      deterministic=deterministic,
                      render=False,
                  )
                  ParallelRolloutWorker._log_episode_info(
                      agent_seed=agent_seed, env=env
                  )
              except Exception as e:
                  ParallelRolloutWorker._log_episode_info(
                      agent_seed=agent_seed, env=env
                  )
                  ParallelRolloutWorker._log_exception(e)
              finally:
                  if not first_episode:
                      reporting_queue.put(
                          episode_recorder.get_last_episode_data()
                      )
                  first_episode = False
  
      except Exception as exception:
          # Ship exception along with a traceback to the main process
          exception_report = ExceptionReport(
              exception, traceback.format_exc(), env_seed, agent_seed
          )
          reporting_queue.put(exception_report)
          raise
  
imports: import logging
  import traceback
  from collections import namedtuple
  from multiprocessing import Queue, Process
  from queue import Empty
  from typing import Iterable, Tuple
  from omegaconf import DictConfig
  from tqdm import tqdm
  from maze.core.annotations import override
  from maze.core.env.maze_env import MazeEnv
  from maze.core.env.structured_env import StructuredEnv
  from maze.core.log_events.episode_event_log import EpisodeEventLog
  from maze.core.log_events.log_events_writer import LogEventsWriter
  from maze.core.log_events.log_events_writer_registry import LogEventsWriterRegistry
  from maze.core.log_events.log_events_writer_tsv import LogEventsWriterTSV
  from maze.core.log_stats.log_stats import LogStatsAggregator, LogStatsLevel, get_stats_logger
  from maze.core.log_stats.log_stats import LogStatsConsumer, LogStats
  from maze.core.log_stats.log_stats import register_log_stats_writer
  from maze.core.log_stats.log_stats_writer_console import LogStatsWriterConsole
  from maze.core.rollout.rollout_runner import RolloutRunner
  from maze.core.trajectory_recording.writers.trajectory_writer_file import TrajectoryWriterFile
  from maze.core.trajectory_recording.writers.trajectory_writer_registry import TrajectoryWriterRegistry
  from maze.core.utils.factory import ConfigType, CollectionOfConfigType
  from maze.core.wrappers.log_stats_wrapper import LogStatsWrapper
  from maze.core.wrappers.trajectory_recording_wrapper import TrajectoryRecordingWrapper
  from maze.utils.bcolors import BColors
label_desc: Use image node_id 1 for calling the ParallelRolloutWorker obj's underlying member method code with example usage: obj.run(env_config, wrapper_config, agent_config, deterministic, max_episode_steps, record_trajectory, input_directory, reporting_queue, seeding_queue) without return types