code: def test_box_actions_out_of_bound(env: gym.Env):
      """Test out of bound actions in Box action_space.
  
      Environments with Box actions spaces perform clipping inside `step`.
      The expected behaviour is that an action `out-of-bound` has the same effect
      of an action with value exactly at the upper (or lower) bound.
  
      Args:
          env (gym.Env): the gym environment
      """
      env.reset(seed=42)
  
      oob_env = gym.make(env.spec.id, disable_env_checker=True)
      oob_env.reset(seed=42)
  
      assert isinstance(env.action_space, spaces.Box)
      dtype = env.action_space.dtype
      upper_bounds = env.action_space.high
      lower_bounds = env.action_space.low
  
      for i, (is_upper_bound, is_lower_bound) in enumerate(
          zip(
              env.action_space.bounded_above,
              env.action_space.bounded_below,
          )
      ):
          if is_upper_bound:
              obs, _, _, _, _ = env.step(upper_bounds)
              oob_action = upper_bounds.copy()
              oob_action[i] += np.cast[dtype](OOB_VALUE)
  
              assert oob_action[i] > upper_bounds[i]
              oob_obs, _, _, _, _ = oob_env.step(oob_action)
  
              assert np.alltrue(obs == oob_obs)
  
          if is_lower_bound:
              obs, _, _, _, _ = env.step(
                  lower_bounds
              )  # `env` is unwrapped, and in new step API
              oob_action = lower_bounds.copy()
              oob_action[i] -= np.cast[dtype](OOB_VALUE)
  
              assert oob_action[i] < lower_bounds[i]
              oob_obs, _, _, _, _ = oob_env.step(oob_action)
  
              assert np.alltrue(obs == oob_obs)
  
      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 3 for calling a global function with example usage: test_box_actions_out_of_bound(env) without return types