class_docstr: gym.Env wrapper to stack multiple frames.
  
  Useful for training feed-forward agents on dynamic games.
  Only works with gym.spaces.Box environment with 2D single channel frames.
  
  Args:
      env (gym.Env): gym.Env to wrap.
      n_frames (int): number of frames to stack.
      axis (int): Axis to stack frames on. This should be 2 for tensorflow
          and 0 for pytorch.
  
  Raises:
       ValueError: If observation space shape is not 2 dimnesional,
       if the environment is not gym.spaces.Box, or if the specified axis
       is not 0 or 2.
class_docstr_tok: ["gym.Env","wrapper","to","stack","multiple","frames",".","Useful","for","training","feed-forward","agents","on","dynamic","games",".","Only","works","with","gym.spaces.Box","environment","with","2D","single","channel","frames",".","Args",":","env","(","gym.Env",")",":","gym.Env","to","wrap",".","n_frames","(","int",")",":","number","of","frames","to","stack",".","axis","(","int",")",":","Axis","to","stack","frames","on",".","This","should","be","2","for","tensorflow","and","0","for","pytorch",".","Raises",":","ValueError",":","If","observation","space","shape","is","not","2","dimnesional",",","if","the","environment","is","not","gym.spaces.Box",",","or","if","the","specified","axis","is","not","0","or","2","."]
docstr: Stacks and returns the last n_frames.
  
  Returns:
      np.ndarray: stacked observation with shape either
      :math:`(N, n_frames, O*)` or :math:(N, O*, n_frames),
      depending on the axis specified.
docstr_tok: ["Stacks","and","returns","the","last","n_frames",".","Returns",":","np.ndarray",":","stacked","observation","with","shape","either",":","math",":","`","(","N",",","n_frames",",","O","*",")","`","or",":","math",":","(","N",",","O","*",",","n_frames",")",",","depending","on","the","axis","specified","."]
code: def _stack_frames(self):
      """Stacks and returns the last n_frames.
  
      Returns:
          np.ndarray: stacked observation with shape either
          :math:`(N, n_frames, O*)` or :math:(N, O*, n_frames),
          depending on the axis specified.
      """
      return np.stack(self._frames, axis=self._axis)
  
file_path: garage/src/garage/envs/wrappers/stack_frames.py
imports: from collections import deque
  import gym
  import gym.spaces
  import numpy
label_desc: Use image node_id 4 for calling the StackFrames obj's underlying member method code with example usage: obj._stack_frames() and returns: np