class_docstr: Gym environment, running with world model.
  
  Allows passing custom initial frames.
  
  Examples:
    Setup simulated env from some point of real rollout.
      >>> sim_env = SimulatedGymEnv(setable_initial_frames=True, **kwargs)
      >>> real_env = FlatBatchEnv(T2TGymEnv(...))
      >>> while ...:
      >>>   ob, _, _, _ = real_env.step(action)
      >>>   sim_env.add_to_initial_stack(ob)
      >>> sim_env.reset()
      >>> # Continue sim_env rollout.
class_docstr_tok: ["Gym","environment",",","running","with","world","model",".","Allows","passing","custom","initial","frames",".","Examples",":","Setup","simulated","env","from","some","point","of","real","rollout",".",">",">",">","sim_env","=","SimulatedGymEnv","(","setable_initial_frames=True",",","*","*","kwargs",")",">",">",">","real_env","=","FlatBatchEnv","(","T2TGymEnv","(","...",")",")",">",">",">","while","...",":",">",">",">","ob",",","_",",","_",",","_","=","real_env.step","(","action",")",">",">",">","sim_env.add_to_initial_stack","(","ob",")",">",">",">","sim_env.reset","(",")",">",">",">","#","Continue","sim_env","rollout","."]
docstr: Adds new frame to (initial) frame stack, removes last one.
docstr_tok: ["Adds","new","frame","to","(","initial",")","frame","stack",",","removes","last","one","."]
code: def add_to_initial_stack(self, frame):
      """Adds new frame to (initial) frame stack, removes last one."""
      if not self._setable_initial_frames:
          raise ValueError(
              "This instance does not allow to manually set initial frame stack."
          )
      assert_msg = "{}, {}".format(
          frame.shape, self._initial_frames.shape[:1]
      )
      assert frame.shape == self._initial_frames.shape[2:], assert_msg
      initial_frames = np.roll(self._initial_frames, shift=-1, axis=1)
      initial_frames[0, -1, ...] = frame
      self._initial_frames = initial_frames
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import copy
  import os
  import re
  import gym
  import numpy
  import six
  from tensor2tensor.models.research.rl import get_policy
  from tensor2tensor.models.research.rl import make_simulated_env_fn_from_hparams
  from tensor2tensor.rl import rl_utils
  from tensor2tensor.rl.envs.simulated_batch_gym_env import FlatBatchEnv
  from tensor2tensor.utils import hparam
  from tensor2tensor.utils import trainer_lib
  from tensor2tensor.utils.misc_utils import camelcase_to_snakecase
  import tensorflow.compat.v1
label_desc: Use image node_id 4 for calling the SimulatedGymEnv obj's underlying member method code with example usage: obj.add_to_initial_stack(frame) without return types