class_docstr: Augment observations by pixel values.
  
  Observations of this wrapper will be dictionaries of images.
  You can also choose to add the observation of the base environment to this dictionary.
  In that case, if the base environment has an observation space of type :class:`Dict`, the dictionary
  of rendered images will be updated with the base environment's observation. If, however, the observation
  space is of type :class:`Box`, the base environment's observation (which will be an element of the :class:`Box`
  space) will be added to the dictionary under the key "state".
  
  Example:
      >>> import gym
      >>> env = PixelObservationWrapper(gym.make('CarRacing-v1', render_mode="rgb_array"))
      >>> obs = env.reset()
      >>> obs.keys()
      odict_keys(['pixels'])
      >>> obs['pixels'].shape
      (400, 600, 3)
      >>> env = PixelObservationWrapper(gym.make('CarRacing-v1', render_mode="rgb_array"), pixels_only=False)
      >>> obs = env.reset()
      >>> obs.keys()
      odict_keys(['state', 'pixels'])
      >>> obs['state'].shape
      (96, 96, 3)
      >>> obs['pixels'].shape
      (400, 600, 3)
      >>> env = PixelObservationWrapper(gym.make('CarRacing-v1', render_mode="rgb_array"), pixel_keys=('obs',))
      >>> obs = env.reset()
      >>> obs.keys()
      odict_keys(['obs'])
      >>> obs['obs'].shape
      (400, 600, 3)
class_docstr_tok: ["Augment","observations","by","pixel","values",".","Observations","of","this","wrapper","will","be","dictionaries","of","images",".","You","can","also","choose","to","add","the","observation","of","the","base","environment","to","this","dictionary",".","In","that","case",",","if","the","base","environment","has","an","observation","space","of","type",":","class",":","`","Dict","`",",","the","dictionary","of","rendered","images","will","be","updated","with","the","base","environment","'s","observation",".","If",",","however",",","the","observation","space","is","of","type",":","class",":","`","Box","`",",","the","base","environment","'s","observation","(","which","will","be","an","element","of","the",":","class",":","`","Box","`","space",")","will","be","added","to","the","dictionary","under","the","key","``","state","''",".","Example",":",">",">",">","import","gym",">",">",">","env","=","PixelObservationWrapper","(","gym.make","(","'CarRacing-v1","'",",","render_mode=","''","rgb_array","''",")",")",">",">",">","obs","=","env.reset","(",")",">",">",">","obs.keys","(",")","odict_keys","(","[","'pixels","'","]",")",">",">",">","obs","[","'pixels","'","]",".shape","(","400",",","600",",","3",")",">",">",">","env","=","PixelObservationWrapper","(","gym.make","(","'CarRacing-v1","'",",","render_mode=","''","rgb_array","''",")",",","pixels_only=False",")",">",">",">","obs","=","env.reset","(",")",">",">",">","obs.keys","(",")","odict_keys","(","[","'state","'",",","'pixels","'","]",")",">",">",">","obs","[","'state","'","]",".shape","(","96",",","96",",","3",")",">",">",">","obs","[","'pixels","'","]",".shape","(","400",",","600",",","3",")",">",">",">","env","=","PixelObservationWrapper","(","gym.make","(","'CarRacing-v1","'",",","render_mode=","''","rgb_array","''",")",",","pixel_keys=","(","'obs","'",",",")",")",">",">",">","obs","=","env.reset","(",")",">",">",">","obs.keys","(",")","odict_keys","(","[","'obs","'","]",")",">",">",">","obs","[","'obs","'","]",".shape","(","400",",","600",",","3",")"]
code: def _add_pixel_observation(self, wrapped_observation):
      if self._pixels_only:
          observation = collections.OrderedDict()
      elif self._observation_is_dict:
          observation = type(wrapped_observation)(wrapped_observation)
      else:
          observation = collections.OrderedDict()
          observation[STATE_KEY] = wrapped_observation
  
      pixel_observations = {
          pixel_key: self._render(**self._render_kwargs[pixel_key])
          for pixel_key in self._pixel_keys
      }
  
      observation.update(pixel_observations)
  
      return observation
  
file_path: gym/gym/wrappers/pixel_observation.py
imports: import collections
  import copy
  from collections.abc import MutableMapping
  from typing import Any, Dict, List, Optional, Tuple
  import numpy
  import gym
  from gym import spaces
label_desc: Use image node_id 3 for calling the PixelObservationWrapper obj's underlying member method code with example usage: obj._add_pixel_observation(wrapped_observation) and returns: observation