class_docstr: Environment wrapper for OpenAI Gym environments.
class_docstr_tok: ["Environment","wrapper","for","OpenAI","Gym","environments","."]
docstr: Steps the environment.
docstr_tok: ["Steps","the","environment","."]
code: def step(self, action: types.NestedArray) -> dm_env.TimeStep:
      """Steps the environment."""
      if self._reset_next_step:
          return self.reset()
  
      observation, reward, done, info = self._environment.step(action)
      self._reset_next_step = done
      self._last_info = info
  
      # Convert the type of the reward based on the spec, respecting the scalar or
      # array property.
      reward = tree.map_structure(
          lambda x, t: (  # pylint: disable=g-long-lambda
              t.dtype.type(x)
              if np.isscalar(x)
              else np.asarray(x, dtype=t.dtype)
          ),
          reward,
          self.reward_spec(),
      )
  
      if done:
          truncated = info.get("TimeLimit.truncated", False)
          if truncated:
              return dm_env.truncation(reward, observation)
          return dm_env.termination(reward, observation)
      return dm_env.transition(reward, observation)
  
imports: from typing import Any, Dict, List, Optional
  from acme import specs
  from acme import types
  import dm_env
  import gym
  from gym import spaces
  import numpy
  import tree
label_desc: Use image node_id 3 for calling the GymWrapper obj's underlying member method code with example usage: obj.step(action) and returns: dm_env, self, dm_env, dm_env