class_docstr: Common superclass for SAC runners, implementing the main training controls.
docstr: Fill the buffer with initial_buffer_size rollouts by rolling out the initial_sampling_policy.
  
  :param replay_buffer: The replay buffer to use.
  :param initial_sampling_policy: The initial sampling policy used to fill the buffer to the initial fill state.
  :param initial_buffer_size: The initial size of the replay buffer filled by sampling from the initial sampling
      policy.
  :param replay_buffer_seed: A seed for initializing and sampling from the replay buffer.
  :param split_rollouts_into_transitions: Specify whether to split rollouts into individual transitions.
  :param n_rollout_steps: Number of rollouts steps to record in one rollout.
  :param env_factory: Factory function for envs to run rollouts on.
docstr_tok: ["Fill","the","buffer","with","initial_buffer_size","rollouts","by","rolling","out","the","initial_sampling_policy",".",":","param","replay_buffer",":","The","replay","buffer","to","use",".",":","param","initial_sampling_policy",":","The","initial","sampling","policy","used","to","fill","the","buffer","to","the","initial","fill","state",".",":","param","initial_buffer_size",":","The","initial","size","of","the","replay","buffer","filled","by","sampling","from","the","initial","sampling","policy",".",":","param","replay_buffer_seed",":","A","seed","for","initializing","and","sampling","from","the","replay","buffer",".",":","param","split_rollouts_into_transitions",":","Specify","whether","to","split","rollouts","into","individual","transitions",".",":","param","n_rollout_steps",":","Number","of","rollouts","steps","to","record","in","one","rollout",".",":","param","env_factory",":","Factory","function","for","envs","to","run","rollouts","on","."]
code: def init_replay_buffer(
      replay_buffer: BaseReplayBuffer,
      initial_sampling_policy: Union[DictConfig, Policy],
      initial_buffer_size: int,
      replay_buffer_seed: int,
      split_rollouts_into_transitions: bool,
      n_rollout_steps: int,
      env_factory: Callable[[], MazeEnv],
  ) -> None:
      """Fill the buffer with initial_buffer_size rollouts by rolling out the initial_sampling_policy.
  
      :param replay_buffer: The replay buffer to use.
      :param initial_sampling_policy: The initial sampling policy used to fill the buffer to the initial fill state.
      :param initial_buffer_size: The initial size of the replay buffer filled by sampling from the initial sampling
          policy.
      :param replay_buffer_seed: A seed for initializing and sampling from the replay buffer.
      :param split_rollouts_into_transitions: Specify whether to split rollouts into individual transitions.
      :param n_rollout_steps: Number of rollouts steps to record in one rollout.
      :param env_factory: Factory function for envs to run rollouts on.
      """
  
      # Create the log stats aggregator for collecting kpis of initializing the replay buffer
      epoch_stats = LogStatsAggregator(LogStatsLevel.EPOCH)
      replay_stats_logger = get_stats_logger("init_replay_buffer")
      epoch_stats.register_consumer(replay_stats_logger)
  
      dummy_env = env_factory()
      dummy_env.seed(replay_buffer_seed)
      sampling_policy: Policy = Factory(Policy).instantiate(
          initial_sampling_policy,
          action_spaces_dict=dummy_env.action_spaces_dict,
      )
      sampling_policy.seed(replay_buffer_seed)
      rollout_generator = RolloutGenerator(
          env=dummy_env,
          record_next_observations=True,
          record_episode_stats=True,
      )
  
      print(
          f"******* Starting to fill the replay buffer with {initial_buffer_size} transitions *******"
      )
      while len(replay_buffer) < initial_buffer_size:
          trajectory = rollout_generator.rollout(
              policy=sampling_policy, n_steps=n_rollout_steps
          )
  
          if split_rollouts_into_transitions:
              replay_buffer.add_rollout(trajectory)
          else:
              replay_buffer.add_transition(trajectory)
  
          # collect episode statistics
          for step_record in trajectory.step_records:
              if step_record.episode_stats is not None:
                  epoch_stats.receive(step_record.episode_stats)
  
      # Print the kpis from initializing the replay buffer
      epoch_stats.reduce()
      # Remove the consumer again from the aggregator
      epoch_stats.remove_consumer(replay_stats_logger)
  
imports: import copy
  from abc import abstractmethod
  from dataclasses import dataclass
  from typing import Callable, List, Union
  from omegaconf import DictConfig
  from torch.utils.data import Dataset
  from maze.core.agent.policy import Policy
  from maze.core.agent.torch_actor_critic import TorchActorCritic
  from maze.core.agent.torch_policy import TorchPolicy
  from maze.core.agent.torch_state_action_critic import TorchStateActionCritic
  from maze.core.annotations import override
  from maze.core.env.maze_env import MazeEnv
  from maze.core.log_stats.log_stats import LogStatsAggregator, LogStatsLevel, get_stats_logger
  from maze.core.rollout.rollout_generator import RolloutGenerator
  from maze.core.trajectory_recording.datasets.in_memory_dataset import InMemoryDataset
  from maze.core.trajectory_recording.records.trajectory_record import SpacesTrajectoryRecord
  from maze.core.utils.config_utils import SwitchWorkingDirectoryToInput
  from maze.core.utils.factory import Factory
  from maze.train.parallelization.distributed_actors.base_distributed_workers_with_buffer import BaseDistributedWorkersWithBuffer
  from maze.train.parallelization.distributed_actors.dummy_distributed_workers_with_buffer import DummyDistributedWorkersWithBuffer
  from maze.train.parallelization.vector_env.sequential_vector_env import SequentialVectorEnv
  from maze.train.parallelization.vector_env.structured_vector_env import StructuredVectorEnv
  from maze.train.trainers.common.evaluators.rollout_evaluator import RolloutEvaluator
  from maze.train.trainers.common.model_selection.best_model_selection import BestModelSelection
  from maze.train.trainers.common.replay_buffer.replay_buffer import BaseReplayBuffer
  from maze.train.trainers.common.replay_buffer.uniform_replay_buffer import UniformReplayBuffer
  from maze.train.trainers.common.training_runner import TrainingRunner
  from maze.train.trainers.sac.sac_trainer import SAC
  from maze.utils.process import query_cpu
label_desc: Use image node_id 4 for calling the SACRunner obj's underlying member method code with example usage: obj.init_replay_buffer(replay_buffer, initial_sampling_policy, initial_buffer_size, replay_buffer_seed, split_rollouts_into_transitions, n_rollout_steps, env_factory) without return types