class_docstr: [OpenAI Gym](https://gym.openai.com/) environment adapter (specification key: `gym`,
  `openai_gym`).
  
  May require:
  ```bash
  pip3 install gym
  pip3 install gym[all]
  ```
  
  Args:
      level (string | gym.Env): Gym id or instance
          (<span style="color:#C00000"><b>required</b></span>).
      visualize (bool): Whether to visualize interaction
          (<span style="color:#00C000"><b>default</b></span>: false).
      min_value (float): Lower bound clipping for otherwise unbounded state values
          (<span style="color:#00C000"><b>default</b></span>: no clipping).
      max_value (float): Upper bound clipping for otherwise unbounded state values
          (<span style="color:#00C000"><b>default</b></span>: no clipping).
      terminal_reward (float): Additional reward for early termination, if otherwise
          indistinguishable from termination due to maximum number of timesteps
          (<span style="color:#00C000"><b>default</b></span>: Gym default).
      reward_threshold (float): Gym environment argument, the reward threshold before the task is
          considered solved
          (<span style="color:#00C000"><b>default</b></span>: Gym default).
      drop_states_indices (list[int]): Drop states indices
          (<span style="color:#00C000"><b>default</b></span>: none).
      visualize_directory (string): Visualization output directory
          (<span style="color:#00C000"><b>default</b></span>: none).
      kwargs: Additional Gym environment arguments.
class_docstr_tok: ["[","OpenAI","Gym","]","(","https",":","\/\/gym.openai.com\/",")","environment","adapter","(","specification","key",":","`","gym","`",",","`","openai_gym","`",")",".","May","require",":","``","`","bash","pip3","install","gym","pip3","install","gym","[","all","]","``","`","Args",":","level","(","string","|","gym.Env",")",":","Gym","id","or","instance","(","<","span","style=","''","color",":","#","C00000","''",">","<","b",">","required","<","\/b",">","<","\/span",">",")",".","visualize","(","bool",")",":","Whether","to","visualize","interaction","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","false",")",".","min_value","(","float",")",":","Lower","bound","clipping","for","otherwise","unbounded","state","values","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","no","clipping",")",".","max_value","(","float",")",":","Upper","bound","clipping","for","otherwise","unbounded","state","values","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","no","clipping",")",".","terminal_reward","(","float",")",":","Additional","reward","for","early","termination",",","if","otherwise","indistinguishable","from","termination","due","to","maximum","number","of","timesteps","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","Gym","default",")",".","reward_threshold","(","float",")",":","Gym","environment","argument",",","the","reward","threshold","before","the","task","is","considered","solved","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","Gym","default",")",".","drop_states_indices","(","list","[","int","]",")",":","Drop","states","indices","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","none",")",".","visualize_directory","(","string",")",":","Visualization","output","directory","(","<","span","style=","''","color",":","#","00C000","''",">","<","b",">","default","<","\/b",">","<","\/span",">",":","none",")",".","kwargs",":","Additional","Gym","environment","arguments","."]
code: def create_level(
      cls, level, max_episode_steps, reward_threshold, **kwargs
  ):
      import gym
  
      requires_register = False
  
      # Find level
      if level not in gym.envs.registry.env_specs:
          if (
              max_episode_steps is None
          ):  # interpret as false if level does not exist
              max_episode_steps = False
          env_specs = list(gym.envs.registry.env_specs)
          if level + "-v0" in gym.envs.registry.env_specs:
              env_specs.insert(0, level + "-v0")
          search = level
          level = None
          for name in env_specs:
              if search == name[: name.rindex("-v")]:
                  if level is None:
                      level = name
                  if (
                      max_episode_steps is False
                      and gym.envs.registry.env_specs[
                          name
                      ].max_episode_steps
                      is not None
                  ):
                      continue
                  elif (
                      max_episode_steps
                      != gym.envs.registry.env_specs[
                          name
                      ].max_episode_steps
                  ):
                      continue
                  level = name
                  break
          else:
              if level is None:
                  raise TensorforceError.value(
                      name="OpenAIGym", argument="level", value=level
                  )
      assert level in cls.levels()
  
      # Check/update attributes
      if max_episode_steps is None:
          max_episode_steps = gym.envs.registry.env_specs[
              level
          ].max_episode_steps
          if max_episode_steps is None:
              max_episode_steps = False
      elif (
          max_episode_steps
          != gym.envs.registry.env_specs[level].max_episode_steps
      ):
          if not (
              (max_episode_steps is False)
              and (
                  gym.envs.registry.env_specs[level].max_episode_steps
                  is None
              )
          ):
              requires_register = True
      if reward_threshold is None:
          reward_threshold = gym.envs.registry.env_specs[
              level
          ].reward_threshold
      elif (
          reward_threshold
          != gym.envs.registry.env_specs[level].reward_threshold
      ):
          requires_register = True
  
      if max_episode_steps is False:
          max_episode_steps = None
  
      # Modified specification
      if requires_register:
          entry_point = gym.envs.registry.env_specs[level].entry_point
          _kwargs = dict(gym.envs.registry.env_specs[level].kwargs)
          nondeterministic = gym.envs.registry.env_specs[
              level
          ].nondeterministic
  
          if (
              "-v" in level
              and level[level.rindex("-v") + 2 :].isdigit()
          ):
              version = int(level[level.rindex("-v") + 2 :])
              level = level[: level.rindex("-v") + 2]
          else:
              version = -1
          while True:
              version += 1
              if (
                  level + str(version)
                  not in gym.envs.registry.env_specs
              ):
                  level = level + str(version)
                  break
  
          gym.register(
              id=level,
              entry_point=entry_point,
              reward_threshold=reward_threshold,
              nondeterministic=nondeterministic,
              max_episode_steps=max_episode_steps,
              kwargs=_kwargs,
          )
          assert level in cls.levels()
  
      return gym.make(id=level, **kwargs), max_episode_steps
  
file_path: tensorforce/tensorforce/environments/openai_gym.py
imports: import importlib
  import numpy
  from tensorforce import TensorforceError, util
  from tensorforce.environments import Environment
label_desc: Use image node_id 2 for calling the OpenAIGym obj's underlying member method code with example usage: obj.create_level(cls, level, max_episode_steps, reward_threshold) and returns: gym,  max_episode_steps