class_docstr: An wrapper stacking the observations of multiple subsequent time steps.
  
  Provides functionality for:
  
      - selecting which observations to stack
      - how many past observations should be stacked
      - stacking deltas with the current step observation (instead of the observations itself)
  
  :param env: Environment/wrapper to wrap.
  :param stack_config: The observation stacking configuration.
  
      observation:        The name (key) of the respective observation
      keep_original:      Bool, indicates weather to keep or remove the original observation from the dictionary.
      tag:                Optional[str], tag to add to observation (e.g. stacked)
      delta:              Bool, if true deltas are stacked to the previous observation
      stack_steps:        Int, number of past steps to be stacked
docstr: Initialize observation stacking for all sub steps and all dictionary observations.
          
docstr_tok: ["Initialize","observation","stacking","for","all","sub","steps","and","all","dictionary","observations","."]
code: def _initialize_stacking(self) -> None:
      """Initialize observation stacking for all sub steps and all dictionary observations."""
  
      # iterate stacking config
      for mapping in self.stack_config:
          obs_key = mapping["observation"]
          assert (
              obs_key in self._flat_observation_space.spaces
          ), f"Observation {obs_key} not contained in flat observation space."
  
          # iterate all structured env sub steps and update observation spaces accordingly
          for (
              sub_step_key,
              sub_space,
          ) in self._original_observation_spaces_dict.items():
              if obs_key in sub_space.spaces:
                  # nothing to stack
                  stack_steps = mapping["stack_steps"]
                  if stack_steps < 2:
                      continue
  
                  # get current space
                  cur_space = self.observation_spaces_dict[
                      sub_step_key
                  ][obs_key]
  
                  # compute stacked low / high
                  if mapping["delta"]:
                      float_max = np.finfo(np.float32).max
                      float_min = np.finfo(np.float32).min
  
                      # compute delta lows and highs
                      mask = cur_space.low > float_min
                      delta_min = np.full(
                          cur_space.low.shape,
                          fill_value=float_min,
                          dtype=cur_space.dtype,
                      )
                      delta_min[mask] = np.clip(
                          cur_space.low[mask] - cur_space.high[mask],
                          float_min,
                          None,
                      )
  
                      mask = cur_space.high < float_max
                      delta_max = np.full(
                          cur_space.high.shape,
                          fill_value=float_max,
                          dtype=cur_space.dtype,
                      )
                      delta_max[mask] = np.clip(
                          cur_space.high[mask] + cur_space.high[mask],
                          None,
                          float_max,
                      )
  
                      low = np.stack(
                          [delta_min] * (stack_steps - 1)
                          + [cur_space.low]
                      )
                      high = np.stack(
                          [delta_max] * (stack_steps - 1)
                          + [cur_space.high]
                      )
                  else:
                      low = np.stack([cur_space.low] * stack_steps)
                      high = np.stack([cur_space.high] * stack_steps)
  
                  # remove original key from observation space
                  if not mapping["keep_original"]:
                      self.observation_spaces_dict[
                          sub_step_key
                      ].spaces.pop(obs_key)
  
                  # add stacked observation space
                  full_tag = (
                      obs_key
                      if mapping["tag"] is None
                      else f"{obs_key}-{mapping['tag']}"
                  )
                  new_space = spaces.Box(
                      low=low,
                      high=high,
                      shape=None,
                      dtype=cur_space.dtype,
                  )
                  self.observation_spaces_dict[sub_step_key].spaces[
                      full_tag
                  ] = new_space
                  assert cur_space.low.ndim == (new_space.low.ndim - 1)
  
imports: import copy
  from collections import defaultdict
  from typing import Any, Dict, List, Tuple, Union, Optional
  import numpy
  from gym import spaces
  from maze.core.annotations import override
  from maze.core.env.maze_action import MazeActionType
  from maze.core.env.maze_env import MazeEnv
  from maze.core.env.maze_state import MazeStateType
  from maze.core.env.simulated_env_mixin import SimulatedEnvMixin
  from maze.core.env.structured_env_spaces_mixin import StructuredEnvSpacesMixin
  from maze.core.utils.structured_env_utils import flat_structured_space
  from maze.core.wrappers.wrapper import ObservationWrapper, Wrapper
label_desc: Use image node_id 4 for calling the ObservationStackWrapper obj's underlying member method code with example usage: obj._initialize_stacking() without return types