docstr: First execute a fixed number of eval rollouts and then continue with producing training samples.
docstr_tok: ["First","execute","a","fixed","number","of","eval","rollouts","and","then","continue","with","producing","training","samples","."]
code: def generate_rollouts(
      self,
      policy: Union[Policy, TorchModel],
      max_steps: Optional[int],
      noise_stddev: float,
      normalization_stats: StructuredStatisticsType,
  ) -> Generator[ESRolloutResult, None, None]:
      """First execute a fixed number of eval rollouts and then continue with producing training samples."""
      self.broadcasting_container.set_policy_state_dict(
          state_dict=policy.state_dict(),
          aux_data=dict(
              normalization_stats=normalization_stats,
              max_steps=max_steps,
              noise_stddev=noise_stddev,
          ),
      )
      current_policy_version = (
          self.broadcasting_container.policy_version()
      )
  
      if not self._workers_started:
          # Start workers if not yet started
          self._start_worker_processes(policy)
          self._workers_started = True
      else:
          # Notify workers to abort current rollout and start a new one
          for worker in self.workers:
              if worker.is_alive():
                  os.kill(worker.pid, signal.SIGUSR1)
  
      while True:
          policy_version, result = self.worker_output_queue.get()
  
          if current_policy_version == policy_version:
              yield result
  
imports: import logging
  import multiprocessing
  import os
  import signal
  from multiprocessing.context import BaseContext
  from typing import Union, Optional, Generator, Callable, List
  import cloudpickle
  from maze.core.agent.policy import Policy
  from maze.core.agent.torch_model import TorchModel
  from maze.core.annotations import override
  from maze.core.env.maze_env import MazeEnv
  from maze.core.wrappers.observation_normalization.normalization_strategies.base import StructuredStatisticsType
  from maze.train.parallelization.broadcasting_container import BroadcastingManager, BroadcastingContainer
  from maze.train.trainers.es.distributed.es_distributed_rollouts import ESDistributedRollouts, ESRolloutResult
  from maze.train.trainers.es.distributed.es_subproc_worker import ESSubprocWorker
  from maze.train.trainers.es.es_shared_noise_table import SharedNoiseTable
label_desc: Use image node_id 2 for calling the ESSubprocDistributedRollouts obj's underlying member method code with example usage: obj.generate_rollouts(policy, max_steps, noise_stddev, normalization_stats) without return types