code: def check_env(
      env: gym.Env, warn: bool = True, skip_render_check: bool = True
  ) -> None:
      """
      Check that an environment follows Gym API.
      This is particularly useful when using a custom environment.
      Please take a look at https://github.com/openai/gym/blob/master/gym/core.py
      for more information about the API.
  
      It also optionally check that the environment is compatible with Stable-Baselines.
  
      :param env: (gym.Env) The Gym environment that will be checked
      :param warn: (bool) Whether to output additional warnings
          mainly related to the interaction with Stable Baselines
      :param skip_render_check: (bool) Whether to skip the checks for the render method.
          True by default (useful for the CI)
      """
      assert isinstance(env, gym.Env), (
          "Your environment must inherit from the gym.Env class "
          "cf https://github.com/openai/gym/blob/master/gym/core.py"
      )
  
      # ============= Check the spaces (observation and action) ================
      _check_spaces(env)
  
      # Define aliases for convenience
      observation_space = env.observation_space
      action_space = env.action_space
  
      # Warn the user if needed.
      # A warning means that the environment may run but not work properly with Stable Baselines algorithms
      if warn:
          _check_unsupported_obs_spaces(env, observation_space)
  
          # If image, check the low and high values, the type and the number of channels
          # and the shape (minimal value)
          if (
              isinstance(observation_space, spaces.Box)
              and len(observation_space.shape) == 3
          ):
              _check_image_input(observation_space)
  
          if isinstance(observation_space, spaces.Box) and len(
              observation_space.shape
          ) not in [1, 3]:
              warnings.warn(
                  "Your observation has an unconventional shape (neither an image, nor a 1D vector). "
                  "We recommend you to flatten the observation "
                  "to have only a 1D vector"
              )
  
          # Check for the action space, it may lead to hard-to-debug issues
          if isinstance(action_space, spaces.Box) and (
              np.any(
                  np.abs(action_space.low) != np.abs(action_space.high)
              )
              or np.any(np.abs(action_space.low) > 1)
              or np.any(np.abs(action_space.high) > 1)
          ):
              warnings.warn(
                  "We recommend you to use a symmetric and normalized Box action space (range=[-1, 1]) "
                  "cf https://stable-baselines.readthedocs.io/en/master/guide/rl_tips.html"
              )
  
      # ============ Check the returned values ===============
      _check_returned_values(env, observation_space, action_space)
  
      # ==== Check the render method and the declared render modes ====
      if not skip_render_check:
          _check_render(env, warn=warn)
  
      # The check only works with numpy arrays
      if _enforce_array_obs(observation_space):
          _check_nan(env)
  
file_path: stable-baselines/stable_baselines/common/env_checker.py
imports: import warnings
  from typing import Union
  import gym
  from gym import spaces
  import numpy
  from stable_baselines.common.vec_env import DummyVecEnv, VecCheckNan
label_desc: Use image node_id 9 for calling a global function with example usage: check_env(env, warn, skip_render_check) without return types