code: def test_make_render_mode():
      env = gym.make("CartPole-v1", disable_env_checker=True)
      assert env.render_mode is None
      env.close()
  
      # Make sure that render_mode is applied correctly
      env = gym.make(
          "CartPole-v1",
          render_mode="rgb_array_list",
          disable_env_checker=True,
      )
      assert env.render_mode == "rgb_array_list"
      env.reset()
      renders = env.render()
      assert isinstance(
          renders, list
      )  # Make sure that the `render` method does what is supposed to
      assert isinstance(renders[0], np.ndarray)
      env.close()
  
      env = gym.make(
          "CartPole-v1", render_mode=None, disable_env_checker=True
      )
      assert env.render_mode is None
      valid_render_modes = env.metadata["render_modes"]
      env.close()
  
      assert len(valid_render_modes) > 0
      with warnings.catch_warnings(record=True) as caught_warnings:
          env = gym.make(
              "CartPole-v1",
              render_mode=valid_render_modes[0],
              disable_env_checker=True,
          )
          assert env.render_mode == valid_render_modes[0]
          env.close()
  
      for warning in caught_warnings:
          raise gym.error.Error(
              f"Unexpected warning: {warning.message}"
          )
  
      # Make sure that native rendering is used when possible
      env = gym.make(
          "CartPole-v1", render_mode="human", disable_env_checker=True
      )
      assert not has_wrapper(
          env, HumanRendering
      )  # Should use native human-rendering
      assert env.render_mode == "human"
      env.close()
  
      with pytest.warns(
          UserWarning,
          match=re.escape(
              "You are trying to use 'human' rendering for an environment that doesn't natively support it. The HumanRendering wrapper is being applied to your environment."
          ),
      ):
          # Make sure that `HumanRendering` is applied here
          env = gym.make(
              "test/NoHuman-v0",
              render_mode="human",
              disable_env_checker=True,
          )  # This environment doesn't use native rendering
          assert has_wrapper(env, HumanRendering)
          assert env.render_mode == "human"
          env.close()
  
      with pytest.raises(
          TypeError,
          match=re.escape(
              "got an unexpected keyword argument 'render_mode'"
          ),
      ):
          gym.make(
              "test/NoHumanOldAPI-v0",
              render_mode="rgb_array_list",
              disable_env_checker=True,
          )
  
      # Make sure that an additional error is thrown a user tries to use the wrapper on an environment with old API
      with warnings.catch_warnings(record=True):
          with pytest.raises(
              gym.error.Error,
              match=re.escape(
                  "You passed render_mode='human' although test/NoHumanOldAPI-v0 doesn't implement human-rendering natively."
              ),
          ):
              gym.make(
                  "test/NoHumanOldAPI-v0",
                  render_mode="human",
                  disable_env_checker=True,
              )
  
      # This test ensures that the additional exception "Gym tried to apply the HumanRendering wrapper but it looks like
      # your environment is using the old rendering API" is *not* triggered by a TypeError that originate from
      # a keyword that is not `render_mode`
      with pytest.raises(
          TypeError,
          match=re.escape(
              "got an unexpected keyword argument 'render'"
          ),
      ):
          gym.make("CarRacing-v2", render="human")
  
imports: import re
  import warnings
  from copy import deepcopy
  import numpy
  import pytest
  import gym
  from gym.envs.classic_control import cartpole
  from gym.wrappers import AutoResetWrapper, HumanRendering, OrderEnforcing, TimeLimit
  from gym.wrappers.env_checker import PassiveEnvChecker
  from tests.envs.test_envs import PASSIVE_CHECK_IGNORE_WARNING
  from tests.envs.utils import all_testing_env_specs
  from tests.envs.utils_envs import ArgumentEnv, RegisterDuringMakeEnv
  from tests.testing_env import GenericTestEnv, old_step_fn
  from tests.wrappers.utils import has_wrapper
label_desc: Use image node_id 9 for calling a global function with example usage: test_make_render_mode() without return types