class_docstr: A wrapper which stacks previously seen frames.
class_docstr_tok: ["A","wrapper","which","stacks","previously","seen","frames","."]
code: def simulate(self, action):
      reward, done = self._batch_env.simulate(action)
      with tf.control_dependencies([reward, done]):
          new_observ = tf.expand_dims(self._batch_env.observ, axis=1)
  
          # If we shouldn't stack, i.e. self.history == 1, then just assign
          # new_observ to self._observ and return from here.
          if self.history == 1:
              with tf.control_dependencies(
                  [self._observ.assign(new_observ)]
              ):
                  return tf.identity(reward), tf.identity(done)
  
          # If we should stack, then do the required work.
          old_observ = tf.gather(
              self._observ.read_value(),
              list(range(1, self.history)),
              axis=1,
          )
          with tf.control_dependencies([new_observ, old_observ]):
              with tf.control_dependencies(
                  [
                      self._observ.assign(
                          tf.concat([old_observ, new_observ], axis=1)
                      )
                  ]
              ):
                  return tf.identity(reward), tf.identity(done)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from six.moves import range
  from tensor2tensor.rl.envs.in_graph_batch_env import InGraphBatchEnv
  import tensorflow.compat.v1
label_desc: Use image node_id 4 for calling the StackWrapper obj's underlying member method code with example usage: obj.simulate(action) and returns: tf,  tf, tf,  tf