class_docstr: A class implementing image preprocessing for Atari 2600 agents.
  
  Specifically, this provides the following subset from the JAIR paper
  (Bellemare et al., 2013) and Nature DQN paper (Mnih et al., 2015):
  
    * Frame skipping (defaults to 4).
    * Terminal signal when a life is lost (off by default).
    * Grayscale and max-pooling of the last two frames.
    * Downsample the screen to a square image (defaults to 84x84).
  
  More generally, this class follows the preprocessing guidelines set down in
  Machado et al. (2018), "Revisiting the Arcade Learning Environment:
  Evaluation Protocols and Open Problems for General Agents".
docstr: Constructor for an Atari 2600 preprocessor.
  
  Args:
    env: Gym environment whose observations are preprocessed.
    frame_skip: int, the frequency at which the agent experiences the game.
    terminal_on_life_loss: bool, If True, the step() method returns
      is_terminal=True whenever a life is lost. See Mnih et al. 2015.
    screen_size: int, size of a resized Atari 2600 frame.
  
  Raises:
    ValueError: if frame_skip or screen_size are not strictly positive.
docstr_tok: ["Constructor","for","an","Atari","2600","preprocessor",".","Args",":","env",":","Gym","environment","whose","observations","are","preprocessed",".","frame_skip",":","int",",","the","frequency","at","which","the","agent","experiences","the","game",".","terminal_on_life_loss",":","bool",",","If","True",",","the","step","(",")","method","returns","is_terminal=True","whenever","a","life","is","lost",".","See","Mnih","et","al",".","2015.","screen_size",":","int",",","size","of","a","resized","Atari","2600","frame",".","Raises",":","ValueError",":","if","frame_skip","or","screen_size","are","not","strictly","positive","."]
code: def __init__(
      self,
      env: gym.Env,
      frame_skip: int = 4,
      terminal_on_life_loss: bool = False,
      screen_size: int = 84,
  ):
      """Constructor for an Atari 2600 preprocessor.
  
      Args:
        env: Gym environment whose observations are preprocessed.
        frame_skip: int, the frequency at which the agent experiences the game.
        terminal_on_life_loss: bool, If True, the step() method returns
          is_terminal=True whenever a life is lost. See Mnih et al. 2015.
        screen_size: int, size of a resized Atari 2600 frame.
  
      Raises:
        ValueError: if frame_skip or screen_size are not strictly positive.
      """
      super(AtariPreprocessing, self).__init__(env)
  
      # Return the observation space adjusted to match the shape of the processed
      # observations.
      self.observation_space = box.Box(
          low=0,
          high=255,
          shape=(screen_size, screen_size, 1),
          dtype=np.uint8,
      )
  
      if frame_skip <= 0:
          raise ValueError(
              "Frame skip should be strictly positive, got {}".format(
                  frame_skip
              )
          )
      if screen_size <= 0:
          raise ValueError(
              "Target screen size should be strictly positive, got {}".format(
                  screen_size
              )
          )
  
      self.terminal_on_life_loss = terminal_on_life_loss
      self.frame_skip = frame_skip
      self.screen_size = screen_size
  
      obs_dims = self.env.observation_space
      # Stores temporary observations used for pooling over two successive
      # frames.
      self.screen_buffer = [
          np.empty(
              (obs_dims.shape[0], obs_dims.shape[1]), dtype=np.uint8
          ),
          np.empty(
              (obs_dims.shape[0], obs_dims.shape[1]), dtype=np.uint8
          ),
      ]
  
      self.game_over = False
      self.lives = 0
  
file_path: agents/tf_agents/environments/atari_preprocessing.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import cv2
  import gin
  import gym
  from gym import core
  from gym.spaces import box
  import numpy
label_desc: Use image node_id 1 to create a new AtariPreprocessing object from inherited base classes: gym_core with example: obj = AtariPreprocessing(env, frame_skip, terminal_on_life_loss, screen_size)