class_docstr: An observation pre-processing wrapper.
  It provides functionality for:
  
  - pre-processing observations (flattening, one-hot encoding, ...)
  - adopting the observation spaces accordingly
  
  :param env: Environment/wrapper to wrap.
  :param pre_processor_mapping: The pre-processing configuration.
         Example mappings can be found in our reference documentation.
class_docstr_tok: ["An","observation","pre-processing","wrapper",".","It","provides","functionality","for",":","-","pre-processing","observations","(","flattening",",","one-hot","encoding",",","...",")","-","adopting","the","observation","spaces","accordingly",":","param","env",":","Environment\/wrapper","to","wrap",".",":","param","pre_processor_mapping",":","The","pre-processing","configuration",".","Example","mappings","can","be","found","in","our","reference","documentation","."]
docstr: Initialize pre-processors for all sub steps and all dictionary observations.
          
docstr_tok: ["Initialize","pre-processors","for","all","sub","steps","and","all","dictionary","observations","."]
code: def _initialize_preprocessors(self) -> None:
      """Initialize pre-processors for all sub steps and all dictionary observations."""
  
      # get full flat observation space
      observation_spaces = flat_structured_space(
          self.observation_spaces_dict
      ).spaces
  
      # maintain a list of temporary spaces
      temporary_spaces = []
  
      # iterate pre-processor config
      for mapping in self.pre_processor_mapping:
          obs_key = mapping["observation"]
          assert (
              obs_key in observation_spaces
          ), f"Observation {obs_key} not contained in observation space."
  
          pre_processor_cls = Factory(PreProcessor).type_from_name(
              mapping["_target_"]
          )
          assert isinstance(
              mapping["config"], Mapping
          ), f"Make sure that the config for {pre_processor_cls.__name__} of observation {obs_key} is a dict!"
          processor = pre_processor_cls(
              observation_space=observation_spaces[obs_key],
              **mapping["config"],
          )
  
          self._preprocessors.append(
              (obs_key, processor, mapping["keep_original"])
          )
  
          # append processed space
          tag = f"{obs_key}-{processor.tag()}"
          observation_spaces[tag] = processor.processed_space()
  
          # iterate all structured env sub steps and update observation spaces accordingly
          for (
              sub_step_key,
              sub_space,
          ) in self.observation_spaces_dict.items():
              # check if the subspace is contained
              if obs_key in sub_space.spaces:
                  # add new key to observation space
                  self.observation_spaces_dict[sub_step_key].spaces[
                      tag
                  ] = processor.processed_space()
  
                  # remove original key from observation space
                  if not mapping["keep_original"]:
                      temporary_spaces.append((sub_step_key, obs_key))
  
      # remove temporary spaces
      for sub_step_key, obs_key in temporary_spaces:
          self.observation_spaces_dict[sub_step_key].spaces.pop(obs_key)
  
file_path: maze/maze/core/wrappers/observation_preprocessing/preprocessing_wrapper.py
imports: from typing import Any, Dict, List, Tuple, Mapping
  from maze.core.annotations import override
  from maze.core.env.maze_env import MazeEnv
  from maze.core.env.simulated_env_mixin import SimulatedEnvMixin
  from maze.core.env.structured_env_spaces_mixin import StructuredEnvSpacesMixin
  from maze.core.utils.factory import Factory
  from maze.core.utils.structured_env_utils import flat_structured_space
  from maze.core.wrappers.observation_preprocessing.preprocessors.base import PreProcessor
  from maze.core.wrappers.wrapper import ObservationWrapper
label_desc: Use image node_id 3 for calling the PreProcessingWrapper obj's underlying member method code with example usage: obj._initialize_preprocessors() without return types