code: def test_get_filtered_observation_space():
      # error on wrong number of channels
      with pytest.raises(ValueError):
          observation_filters = InputFilter()
          observation_filters.add_observation_filter(
              "observation",
              "rescale",
              ObservationRescaleToSizeFilter(
                  ImageObservationSpace(np.array([5, 10, 5]), high=255)
              ),
          )
  
      # mismatch and wrong number of channels
      rescale_filter = InputFilter()
      rescale_filter.add_observation_filter(
          "observation",
          "rescale",
          ObservationRescaleToSizeFilter(
              ImageObservationSpace(np.array([5, 10, 3]), high=255)
          ),
      )
  
      observation_space = PlanarMapsObservationSpace(
          np.array([10, 20, 5]), low=0, high=255
      )
      with pytest.raises(ValueError):
          rescale_filter.get_filtered_observation_space(
              "observation", observation_space
          )
  
      # error on wrong number of dimensions
      observation_space = ObservationSpace(
          np.array([10, 20, 10, 3]), high=255
      )
      with pytest.raises(ValueError):
          rescale_filter.get_filtered_observation_space(
              "observation", observation_space
          )
  
      # make sure the new observation space shape is calculated correctly
      observation_space = ImageObservationSpace(
          np.array([10, 20, 3]), high=255
      )
      filtered_observation_space = (
          rescale_filter.get_filtered_observation_space(
              "observation", observation_space
          )
      )
      assert np.all(
          filtered_observation_space.shape == np.array([5, 10, 3])
      )
  
      # make sure the original observation space is unchanged
      assert np.all(observation_space.shape == np.array([10, 20, 3]))
  
file_path: coach/rl_coach/tests/filters/observation/test_observation_rescale_to_size_filter.py
imports: import os
  import sys
  import pytest
  import numpy
  from rl_coach.filters.observation.observation_rescale_to_size_filter import ObservationRescaleToSizeFilter
  from rl_coach.spaces import ObservationSpace, ImageObservationSpace, PlanarMapsObservationSpace
  from rl_coach.core_types import EnvResponse
  from rl_coach.filters.filter import InputFilter
label_desc: Use image node_id 2 for calling a global function with example usage: test_get_filtered_observation_space() without return types