class_docstr: Returns an abstract Garage wrapper class for gym.Env.
  
  In order to provide pickling (serialization) and parameterization
  for :class:`gym.Env` instances, they must be wrapped with :class:`GymEnv`.
  This ensures compatibility with existing samplers and checkpointing when
  the envs are passed internally around garage.
  
  Furthermore, classes inheriting from :class:`GymEnv` should silently
  convert :attribute:`action_space` and :attribute:`observation_space`
  from :class:`gym.Space` to :class:`akro.Space`.
  
  :class:`GymEnv` handles all environments created by :func:`~gym.make`.
  
  It returns a different wrapper class instance if the input environment
  requires special handling.
  Current supported wrapper classes are:
      garage.envs.bullet.BulletEnv for Bullet-based gym environments.
  See __new__() for details.
class_docstr_tok: ["Returns","an","abstract","Garage","wrapper","class","for","gym.Env",".","In","order","to","provide","pickling","(","serialization",")","and","parameterization","for",":","class",":","`","gym.Env","`","instances",",","they","must","be","wrapped","with",":","class",":","`","GymEnv","`",".","This","ensures","compatibility","with","existing","samplers","and","checkpointing","when","the","envs","are","passed","internally","around","garage",".","Furthermore",",","classes","inheriting","from",":","class",":","`","GymEnv","`","should","silently","convert",":","attribute",":","`","action_space","`","and",":","attribute",":","`","observation_space","`","from",":","class",":","`","gym.Space","`","to",":","class",":","`","akro.Space","`",".",":","class",":","`","GymEnv","`","handles","all","environments","created","by",":","func",":","`","~gym.make","`",".","It","returns","a","different","wrapper","class","instance","if","the","input","environment","requires","special","handling",".","Current","supported","wrapper","classes","are",":","garage.envs.bullet.BulletEnv","for","Bullet-based","gym","environments",".","See","__new__","(",")","for","details","."]
docstr: Call step on wrapped env.
  
  Args:
      action (np.ndarray): An action provided by the agent.
  
  Returns:
      EnvStep: The environment step resulting from the action.
  
  Raises:
      RuntimeError: if `step()` is called after the environment has been
          constructed and `reset()` has not been called.
      RuntimeError: if underlying environment outputs inconsistent
          env_info keys.
docstr_tok: ["Call","step","on","wrapped","env",".","Args",":","action","(","np.ndarray",")",":","An","action","provided","by","the","agent",".","Returns",":","EnvStep",":","The","environment","step","resulting","from","the","action",".","Raises",":","RuntimeError",":","if","`","step","(",")","`","is","called","after","the","environment","has","been","constructed","and","`","reset","(",")","`","has","not","been","called",".","RuntimeError",":","if","underlying","environment","outputs","inconsistent","env_info","keys","."]
code: def step(self, action):
      """Call step on wrapped env.
  
      Args:
          action (np.ndarray): An action provided by the agent.
  
      Returns:
          EnvStep: The environment step resulting from the action.
  
      Raises:
          RuntimeError: if `step()` is called after the environment has been
              constructed and `reset()` has not been called.
          RuntimeError: if underlying environment outputs inconsistent
              env_info keys.
  
      """
      if self._step_cnt is None:
          raise RuntimeError("reset() must be called before step()!")
  
      observation, reward, done, info = self._env.step(action)
  
      if self._visualize:
          self._env.render(mode="human")
  
      reward = (
          float(reward) if not isinstance(reward, float) else reward
      )
      self._step_cnt += 1
  
      step_type = StepType.get_step_type(
          step_cnt=self._step_cnt,
          max_episode_length=self._max_episode_length,
          done=done,
      )
  
      # gym envs that are wrapped in TimeLimit wrapper modify
      # the done/termination signal to be true whenever a time
      # limit expiration occurs. The following statement sets
      # the done signal to be True only if caused by an
      # environment termination, and not a time limit
      # termination. The time limit termination signal
      # will be saved inside env_infos as
      # 'GymEnv.TimeLimitTerminated'
      if "TimeLimit.truncated" in info or step_type == StepType.TIMEOUT:
          info["GymEnv.TimeLimitTerminated"] = True
          info["TimeLimit.truncated"] = info.get(
              "TimeLimit.truncated", True
          )
          step_type = StepType.TIMEOUT
      else:
          info["TimeLimit.truncated"] = False
          info["GymEnv.TimeLimitTerminated"] = False
  
      if step_type in (StepType.TERMINAL, StepType.TIMEOUT):
          self._step_cnt = None
  
      # check that env_infos are consistent
      if not self._env_info:
          self._env_info = {k: type(info[k]) for k in info}
      elif self._env_info.keys() != info.keys():
          raise RuntimeError(
              "GymEnv outputs inconsistent env_info keys."
          )
      if not self.spec.observation_space.contains(observation):
          # Discrete actions can be either in the space normally, or one-hot
          # encoded.
          if self.spec.observation_space.flat_dim != np.prod(
              observation.shape
          ):
              raise RuntimeError(
                  "GymEnv observation shape does not "
                  "conform to its observation_space"
              )
  
      return EnvStep(
          env_spec=self.spec,
          action=action,
          reward=reward,
          observation=observation,
          env_info=info,
          step_type=step_type,
      )
  
imports: import copy
  import warnings
  import akro
  import gym
  import numpy
  from garage import Environment, EnvSpec, EnvStep, StepType
label_desc: Use image node_id 8 for calling the GymEnv obj's underlying member method code with example usage: obj.step(action) and returns: EnvStep