class_docstr: Represents configuration of environment spaces (action & observation) used for model config.
  
  Spaces config are needed (together with model config and dumped state dict) when loading
  a trained policy for rollout.
docstr: Return internal state for serialization.
  This is a workaround for unpickle-able objects in DictConfig's _parent node. Ideally this should be made
  redundant by having .instantiate return dicts instead of DictConfigs or any other standardized approach to
  converting DictConfigs as returned from Factory.instantiate() to native dicts.
  :return: Internal state as dictionary.
code: def __getstate__(self) -> Dict[str, Any]:
      """
      Return internal state for serialization.
      This is a workaround for unpickle-able objects in DictConfig's _parent node. Ideally this should be made
      redundant by having .instantiate return dicts instead of DictConfigs or any other standardized approach to
      converting DictConfigs as returned from Factory.instantiate() to native dicts.
      :return: Internal state as dictionary.
      """
  
      # Use Hydra's __get__() to return actual spaces as state instead of Hydra's DictConfig/Node objecs.
      return {
          "action_spaces_dict": {
              key: val for key, val in self.action_spaces_dict.items()
          },
          "observation_spaces_dict": {
              key: val
              for key, val in self.observation_spaces_dict.items()
          },
          "agent_counts_dict": {
              key: val for key, val in self.agent_counts_dict.items()
          },
      }
  
file_path: maze/maze/perception/models/space_config.py
imports: import pickle
  from typing import Dict, Any
  import gym
  from maze.core.env.structured_env import StepKeyType
label_desc: Use image node_id 4 for calling the SpacesConfig obj's underlying member method code with example usage: obj.__getstate__() and returns: dict