code: def test_discrete_actions_out_of_bound(env: gym.Env):
      """Test out of bound actions in Discrete action_space.
  
      In discrete action_space environments, `out-of-bound`
      actions are not allowed and should raise an exception.
  
      Args:
          env (gym.Env): the gym environment
      """
      assert isinstance(env.action_space, spaces.Discrete)
      upper_bound = env.action_space.start + env.action_space.n - 1
  
      env.reset()
      with pytest.raises(Exception):
          env.step(upper_bound + 1)
  
      env.close()
  
file_path: gym/tests/envs/test_action_dim_check.py
imports: import numpy
  import pytest
  import gym
  from gym import spaces
  from gym.envs.registration import EnvSpec
  from tests.envs.utils import all_testing_initialised_envs, mujoco_testing_env_specs
label_desc: Use image node_id 2 for calling a global function with example usage: test_discrete_actions_out_of_bound(env) without return types