class_docstr: Runs rollout in multiple processes in parallel.
  
  Both agent and environment are run in multiple instances across multiple processes. While this greatly speeds
  up the rollout, the memory consumption might be high for large environments and agents.
  
  Trajectory recording, event logging, as well as stats logging are supported. Trajectory logging happens
  in the child processes. Event logs and stats are shipped back to the main process so that they can be
  handled together there. This allows monitoring of progress and calculation of summary stats across
  all the processes.
  
  (Note that the relevant wrappers need to be present in the config for the trajectory/event/stats logging to work.
  Data are logged into the working directory managed by hydra.)
  
  In case of early rollout termination using a keyboard interrupt, data for all episodes completed till that
  point will be preserved (= written out). Graceful shutdown will be attempted, including calculation of statistics
  across the episodes completed before the rollout was terminated.
  
  :param n_episodes: Count of episodes to run.
  :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 n_processes: Count of processes to spread the rollout across.
  :param record_trajectory: Whether to record trajectory data.
  :param record_event_logs: Whether to record event logs.
class_docstr_tok: ["Runs","rollout","in","multiple","processes","in","parallel",".","Both","agent","and","environment","are","run","in","multiple","instances","across","multiple","processes",".","While","this","greatly","speeds","up","the","rollout",",","the","memory","consumption","might","be","high","for","large","environments","and","agents",".","Trajectory","recording",",","event","logging",",","as","well","as","stats","logging","are","supported",".","Trajectory","logging","happens","in","the","child","processes",".","Event","logs","and","stats","are","shipped","back","to","the","main","process","so","that","they","can","be","handled","together","there",".","This","allows","monitoring","of","progress","and","calculation","of","summary","stats","across","all","the","processes",".","(","Note","that","the","relevant","wrappers","need","to","be","present","in","the","config","for","the","trajectory\/event\/stats","logging","to","work",".","Data","are","logged","into","the","working","directory","managed","by","hydra",".",")","In","case","of","early","rollout","termination","using","a","keyboard","interrupt",",","data","for","all","episodes","completed","till","that","point","will","be","preserved","(","=","written","out",")",".","Graceful","shutdown","will","be","attempted",",","including","calculation","of","statistics","across","the","episodes","completed","before","the","rollout","was","terminated",".",":","param","n_episodes",":","Count","of","episodes","to","run",".",":","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","n_processes",":","Count","of","processes","to","spread","the","rollout","across",".",":","param","record_trajectory",":","Whether","to","record","trajectory","data",".",":","param","record_event_logs",":","Whether","to","record","event","logs","."]
docstr: Configure and launch the processes.
          
docstr_tok: ["Configure","and","launch","the","processes","."]
code: def _configure_and_launch_processes(
      self,
      parallel_worker_type: type(ParallelRolloutWorker),
      env: ConfigType,
      wrappers: CollectionOfConfigType,
      agent: ConfigType,
  ) -> Iterable[Process]:
      """Configure and launch the processes."""
      self.reporting_queue = Queue()
      workers = []
      for _ in range(min(self.n_processes, self.n_episodes)):
          p = Process(
              target=parallel_worker_type.run,
              args=(
                  env,
                  wrappers,
                  agent,
                  self.deterministic,
                  self.max_episode_steps,
                  self.record_trajectory,
                  self.input_dir,
                  self.reporting_queue,
                  self.seeding_queue,
              ),
              daemon=True,
          )
          p.start()
          workers.append(p)
  
      # Perform writer registration -- after the forks so that it is not carried over to child processes
      if self.record_event_logs:
          LogEventsWriterRegistry.register_writer(
              LogEventsWriterTSV(log_dir="./event_logs")
          )
      register_log_stats_writer(LogStatsWriterConsole())
      self.epoch_stats_aggregator = LogStatsAggregator(
          LogStatsLevel.EPOCH
      )
      self.epoch_stats_aggregator.register_consumer(
          get_stats_logger("rollout_stats")
      )
  
      return workers
  
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 4 for calling the ParallelRolloutRunner obj's underlying member method code with example usage: obj._configure_and_launch_processes(parallel_worker_type, env, wrappers, agent) and returns: workers