code: def gym_env_wrapper(
      env,
      rl_env_max_episode_steps,
      maxskip_env,
      rendered_env,
      rendered_env_resize_to,
      sticky_actions,
      output_dtype,
      num_actions,
  ):
      """Wraps a gym environment. see make_gym_env for details."""
      # rl_env_max_episode_steps is None or int.
      assert (not rl_env_max_episode_steps) or isinstance(
          rl_env_max_episode_steps, int
      )
  
      wrap_with_time_limit = (
          not rl_env_max_episode_steps
      ) or rl_env_max_episode_steps >= 0
  
      if wrap_with_time_limit:
          env = remove_time_limit_wrapper(env)
  
      if num_actions is not None:
          logging.log_first_n(
              logging.INFO,
              "Number of discretized actions: %d",
              1,
              num_actions,
          )
          env = ActionDiscretizeWrapper(env, num_actions=num_actions)
  
      if sticky_actions:
          env = StickyActionEnv(env)
  
      if maxskip_env:
          env = MaxAndSkipEnv(
              env
          )  # pylint: disable=redefined-variable-type
  
      if rendered_env:
          env = RenderedEnv(
              env,
              resize_to=rendered_env_resize_to,
              output_dtype=output_dtype,
          )
  
      if wrap_with_time_limit and rl_env_max_episode_steps is not None:
          env = gym.wrappers.TimeLimit(
              env, max_episode_steps=rl_env_max_episode_steps
          )
      return env
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import math
  from absl import logging
  import gym
  import gym.wrappers
  import numpy
  from PIL import Image
label_desc: Use image node_id 2 for calling a global function with example usage: gym_env_wrapper(env, rl_env_max_episode_steps, maxskip_env, rendered_env, rendered_env_resize_to, sticky_actions, output_dtype, num_actions) and returns: env