code: def test_gym_wrapper_action_space():
      print("Testing Gym wrapper action spaces")
      env_configs = [
          "basic_rgb_i_1_3",
          "basic_g8_i_1_0",
          "basic_g8_idla_4_2",
          "basic_g8_idl_3_1",
          "basic_rgb_id_2_0",
          "basic_rgb_idla_0_1",
      ]
      action_spaces = [
          # max_button_pressed = 0, binary action space is MultiDiscrete
          [
              Dict(
                  {
                      "binary": MultiDiscrete([2]),
                      "continuous": Box(
                          np.finfo(np.float32).min,
                          np.finfo(np.float32).max,
                          (3,),
                          dtype=np.float32,
                      ),
                  }
              ),
              MultiDiscrete([2]),
              Dict(
                  {
                      "binary": MultiDiscrete([2, 2, 2, 2]),
                      "continuous": Box(
                          np.finfo(np.float32).min,
                          np.finfo(np.float32).max,
                          (2,),
                          dtype=np.float32,
                      ),
                  }
              ),
              Dict(
                  {
                      "binary": MultiDiscrete([2, 2, 2]),
                      "continuous": Box(
                          np.finfo(np.float32).min,
                          np.finfo(np.float32).max,
                          (1,),
                          dtype=np.float32,
                      ),
                  }
              ),
              MultiDiscrete([2, 2]),
              Box(
                  np.finfo(np.float32).min,
                  np.finfo(np.float32).max,
                  (1,),
                  dtype=np.float32,
              ),
          ],
          # max_button_pressed = 1, binary action space is Discrete(num_binary_buttons + 1)
          [
              Dict(
                  {
                      "binary": Discrete(2),
                      "continuous": Box(
                          np.finfo(np.float32).min,
                          np.finfo(np.float32).max,
                          (3,),
                          dtype=np.float32,
                      ),
                  }
              ),
              Discrete(2),
              Dict(
                  {
                      "binary": Discrete(5),
                      "continuous": Box(
                          np.finfo(np.float32).min,
                          np.finfo(np.float32).max,
                          (2,),
                          dtype=np.float32,
                      ),
                  }
              ),
              Dict(
                  {
                      "binary": Discrete(4),
                      "continuous": Box(
                          np.finfo(np.float32).min,
                          np.finfo(np.float32).max,
                          (1,),
                          dtype=np.float32,
                      ),
                  }
              ),
              Discrete(3),
              Box(
                  np.finfo(np.float32).min,
                  np.finfo(np.float32).max,
                  (1,),
                  dtype=np.float32,
              ),
          ],
          # max_button_pressed = 2, binary action space is Discrete(m) m=all combinations
          # indices=[0,1] should give warning clipping max_buttons_pressed to 1
          [
              Dict(
                  {
                      "binary": Discrete(2),
                      "continuous": Box(
                          np.finfo(np.float32).min,
                          np.finfo(np.float32).max,
                          (3,),
                          dtype=np.float32,
                      ),
                  }
              ),
              Discrete(2),
              Dict(
                  {
                      "binary": Discrete(11),
                      "continuous": Box(
                          np.finfo(np.float32).min,
                          np.finfo(np.float32).max,
                          (2,),
                          dtype=np.float32,
                      ),
                  }
              ),
              Dict(
                  {
                      "binary": Discrete(7),
                      "continuous": Box(
                          np.finfo(np.float32).min,
                          np.finfo(np.float32).max,
                          (1,),
                          dtype=np.float32,
                      ),
                  }
              ),
              Discrete(4),
              Box(
                  np.finfo(np.float32).min,
                  np.finfo(np.float32).max,
                  (1,),
                  dtype=np.float32,
              ),
          ],
          # max_button_pressed = 3, binary action space is Discrete(m) m=all combinations
          # indices=[0,1, 4] should give warning clipping max_buttons_pressed to 1 or 2
          [
              Dict(
                  {
                      "binary": Discrete(2),
                      "continuous": Box(
                          np.finfo(np.float32).min,
                          np.finfo(np.float32).max,
                          (3,),
                          dtype=np.float32,
                      ),
                  }
              ),
              Discrete(2),
              Dict(
                  {
                      "binary": Discrete(15),
                      "continuous": Box(
                          np.finfo(np.float32).min,
                          np.finfo(np.float32).max,
                          (2,),
                          dtype=np.float32,
                      ),
                  }
              ),
              Dict(
                  {
                      "binary": Discrete(8),
                      "continuous": Box(
                          np.finfo(np.float32).min,
                          np.finfo(np.float32).max,
                          (1,),
                          dtype=np.float32,
                      ),
                  }
              ),
              Discrete(4),
              Box(
                  np.finfo(np.float32).min,
                  np.finfo(np.float32).max,
                  (1,),
                  dtype=np.float32,
              ),
          ],
      ]
      for max_button_pressed in range(0, 4):
          for i in range(len(env_configs)):
              env = VizdoomEnv(
                  level=os.path.join(
                      test_env_configs, env_configs[i] + ".cfg"
                  ),
                  frame_skip=1,
                  max_buttons_pressed=max_button_pressed,
              )
              assert (
                  env.action_space
                  == action_spaces[max_button_pressed][i]
              ), (
                  f"Incorrect action space: {env.action_space!r}, "
                  f"should be: {action_spaces[max_button_pressed][i]!r}"
              )
              env.reset()
              # check successful call to step using action_space.sample()
              sample_action = env.action_space.sample()
              env.step(sample_action)
  
file_path: ViZDoom/tests/manual_test_gym_wrapper.py
imports: import os
  import gym
  import numpy
  from gym.spaces import Box, Dict, Discrete, MultiDiscrete
  from gym.utils.env_checker import check_env
  from vizdoom import gym_wrapper
  from vizdoom.gym_wrapper.base_gym_env import VizdoomEnv
label_desc: Use image node_id 4 for calling a global function with example usage: test_gym_wrapper_action_space() without return types