class_docstr: Utility class for storing rollouts.
  
  Currently supports two behaviours: the original, which
  simply dumps everything to a pickle file once complete,
  and a mode which stores each rollout as an entry in a Python
  shelf db file. The latter mode is more robust to memory problems
  or crashes part-way through the rollout generation. Each rollout
  is stored with a key based on the episode number (0-indexed),
  and the number of episodes is stored with the key "num_episodes",
  so to load the shelf file, use something like:
  
  with shelve.open('rollouts.pkl') as rollouts:
     for episode_index in range(rollouts["num_episodes"]):
        rollout = rollouts[str(episode_index)]
  
  If outfile is None, this class does nothing.
code: def __init__(
      self,
      outfile=None,
      use_shelve=False,
      write_update_file=False,
      target_steps=None,
      target_episodes=None,
      save_info=False,
  ):
      self._outfile = outfile
      self._update_file = None
      self._use_shelve = use_shelve
      self._write_update_file = write_update_file
      self._shelf = None
      self._num_episodes = 0
      self._rollouts = []
      self._current_rollout = []
      self._total_steps = 0
      self._target_episodes = target_episodes
      self._target_steps = target_steps
      self._save_info = save_info
  
imports: import collections
  import copy
  import gymnasium
  import json
  import os
  from pathlib import Path
  import shelve
  import typer
  import ray
  import ray.cloudpickle
  from ray.rllib.env import MultiAgentEnv
  from ray.rllib.env.base_env import _DUMMY_AGENT_ID
  from ray.rllib.env.env_context import EnvContext
  from ray.rllib.evaluation.worker_set import WorkerSet
  from ray.rllib.policy.sample_batch import DEFAULT_POLICY_ID
  from ray.rllib.utils.spaces.space_utils import flatten_to_single_ndarray
  from ray.rllib.common import CLIArguments
  from ray.train._checkpoint import Checkpoint
  from ray.train._internal.session import _TrainingResult
  from ray.tune.utils import merge_dicts
  from ray.tune.registry import get_trainable_cls, _global_registry, ENV_CREATOR
label_desc: Use image node_id 1 to create a new RolloutSaver object  with example: obj = RolloutSaver(outfile, use_shelve, write_update_file, target_steps, target_episodes, save_info)