class_docstr: Splits an actions into separate ones.
  
  An example is given by the LunarLanderContinuous-v2 env. Here we have a box action spaces with shape (2,) such that
  dimension 0 is the up/down action and dimension 1 is the left/right action. Now if we would like to split this
  action correspondingly we can wrap the env with the following config:
  
  split_config:
      action:
          action_up:
              indices: [0]
          action_side:
              indices: [1]
  
  Now the actions as well as the action space is consists of two actions (action_up/action_side).
  
  :param env: Environment/wrapper to wrap.
  :param split_config: The action splitting configuration.
class_docstr_tok: ["Splits","an","actions","into","separate","ones",".","An","example","is","given","by","the","LunarLanderContinuous-v2","env",".","Here","we","have","a","box","action","spaces","with","shape","(","2",",",")","such","that","dimension","0","is","the","up\/down","action","and","dimension","1","is","the","left\/right","action",".","Now","if","we","would","like","to","split","this","action","correspondingly","we","can","wrap","the","env","with","the","following","config",":","split_config",":","action",":","action_up",":","indices",":","[","0","]","action_side",":","indices",":","[","1","]","Now","the","actions","as","well","as","the","action","space","is","consists","of","two","actions","(","action_up\/action_side",")",".",":","param","env",":","Environment\/wrapper","to","wrap",".",":","param","split_config",":","The","action","splitting","configuration","."]
docstr: Split a single action space (dict) into the corresponding sub actions spaces w.r.t. the split config
  
  :param action_space: The action space to split.
  :return: The resulting (split) action space.
docstr_tok: ["Split","a","single","action","space","(","dict",")","into","the","corresponding","sub","actions","spaces","w.r.t",".","the","split","config",":","param","action_space",":","The","action","space","to","split",".",":","return",":","The","resulting","(","split",")","action","space","."]
code: def _split_action_space(
      self, action_space: gym.spaces.Dict
  ) -> gym.spaces.Dict:
      """Split a single action space (dict) into the corresponding sub actions spaces w.r.t. the split config
  
      :param action_space: The action space to split.
      :return: The resulting (split) action space.
      """
      new_action_space = dict()
      for (
          org_action_name,
          org_action_space,
      ) in action_space.spaces.items():
          if org_action_name in self.split_config:
              for new_action_key, new_space_config in self.split_config[
                  org_action_name
              ].items():
                  if isinstance(org_action_space, gym.spaces.Box):
                      low = [
                          org_action_space.low[select_index]
                          for select_index in new_space_config[
                              "indices"
                          ]
                      ]
                      high = [
                          org_action_space.high[select_index]
                          for select_index in new_space_config[
                              "indices"
                          ]
                      ]
                      new_action_space[new_action_key] = gym.spaces.Box(
                          low=np.asarray(low),
                          high=np.asarray(high),
                          dtype=org_action_space.dtype,
                      )
                  elif isinstance(
                      org_action_space, gym.spaces.MultiDiscrete
                  ):
                      nvec = [
                          org_action_space.nvec[select_index]
                          for select_index in new_space_config[
                              "indices"
                          ]
                      ]
                      if len(nvec) > 1:
                          new_action_space[
                              new_action_key
                          ] = gym.spaces.MultiDiscrete(nvec=nvec)
                      else:
                          new_action_space[
                              new_action_key
                          ] = gym.spaces.Discrete(n=nvec[0])
                  else:
                      assert isinstance(
                          org_action_space, gym.spaces.MultiBinary
                      )
                      new_action_space[
                          new_action_key
                      ] = gym.spaces.MultiBinary(
                          n=len(new_space_config["indices"])
                      )
          else:
              new_action_space[org_action_name] = org_action_space
      return gym.spaces.Dict(new_action_space)
  
file_path: maze/maze/core/wrappers/split_actions_wrapper.py
imports: from typing import Union, Dict, Tuple, List
  import gym
  import numpy
  from maze.core.annotations import override
  from maze.core.env.simulated_env_mixin import SimulatedEnvMixin
  from maze.core.env.structured_env import StructuredEnv
  from maze.core.env.structured_env_spaces_mixin import StructuredEnvSpacesMixin
  from maze.core.wrappers.wrapper import ActionWrapper, EnvType
label_desc: Use image node_id 3 for calling the SplitActionsWrapper obj's underlying member method code with example usage: obj._split_action_space(action_space) and returns: gym