code: def test_dict_observation(pixels_only):
      pixel_key = "rgb"
  
      env = FakeDictObservationEnvironment()
  
      # Make sure we are testing the right environment for the test.
      observation_space = env.observation_space
      assert isinstance(observation_space, spaces.Dict)
  
      width, height = (320, 240)
  
      # The wrapper should only add one observation.
      wrapped_env = PixelObservationWrapper(
          env,
          pixel_keys=(pixel_key,),
          pixels_only=pixels_only,
          render_kwargs={pixel_key: {"width": width, "height": height}},
      )
  
      assert isinstance(wrapped_env.observation_space, spaces.Dict)
  
      if pixels_only:
          assert len(wrapped_env.observation_space.spaces) == 1
          assert list(wrapped_env.observation_space.spaces.keys()) == [
              pixel_key
          ]
      else:
          assert (
              len(wrapped_env.observation_space.spaces)
              == len(observation_space.spaces) + 1
          )
          expected_keys = list(observation_space.spaces.keys()) + [
              pixel_key
          ]
          assert (
              list(wrapped_env.observation_space.spaces.keys())
              == expected_keys
          )
  
      # Check that the added space item is consistent with the added observation.
      observation, info = wrapped_env.reset()
      rgb_observation = observation[pixel_key]
  
      assert isinstance(info, dict)
      assert rgb_observation.shape == (height, width, 3)
      assert rgb_observation.dtype == np.uint8
  
file_path: gym/tests/wrappers/test_pixel_observation.py
imports: from typing import Optional
  import numpy
  import pytest
  import gym
  from gym import spaces
  from gym.wrappers.pixel_observation import STATE_KEY, PixelObservationWrapper
label_desc: Use image node_id 1 for calling a global function with example usage: test_dict_observation(pixels_only) without return types