class_docstr: Randomly generates observations following the given observation_spec.
  
  If an action_spec is provided, it validates that the actions used to step the
  environment are compatible with the given spec.
class_docstr_tok: ["Randomly","generates","observations","following","the","given","observation_spec",".","If","an","action_spec","is","provided",",","it","validates","that","the","actions","used","to","step","the","environment","are","compatible","with","the","given","spec","."]
docstr: Steps the environment according to the action.
docstr_tok: ["Steps","the","environment","according","to","the","action","."]
code: def _step(self, action):
      """Steps the environment according to the action."""
      # Make sure the given action is compatible with the spec. We compare it to
      # t[0] as the spec doesn't have a batch dim.
      tf.nest.map_structure(
          lambda spec, t: tf.Assert(spec.is_compatible_with(t[0]), [t]),
          self._action_spec,
          action,
      )
  
      # If we generalize the batched data to not terminate at the same time, we
      # will need to only reset the correct batch_inidices.
      if self._time_step_variables.is_last()[0]:
          return self.reset()
  
      obs, reward = self._sample_obs_and_reward()
      # Note: everything in the batch terminates at the same time.
      if tf.random.uniform(()) < self._episode_end_probability:
          time_step = ts.termination(obs, reward)
      else:
          time_step = ts.transition(obs, reward)
  
      self._update_time_step(time_step)
      return time_step
  
file_path: agents/tf_agents/environments/random_tf_environment.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow
  from tf_agents.environments import tf_environment
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import time_step
  from tf_agents.utils import common
  from tf_agents.utils import nest_utils
label_desc: Use image node_id 6 for calling the RandomTFEnvironment obj's underlying member method code with example usage: obj._step(action) and returns: time_step, self