code: def test_filter():
      # make an RGB observation smaller
      env_response = EnvResponse(
          next_state={"observation": np.ones([20, 30, 3])},
          reward=0,
          game_over=False,
      )
      rescale_filter = InputFilter()
      rescale_filter.add_observation_filter(
          "observation",
          "rescale",
          ObservationRescaleSizeByFactorFilter(0.5),
      )
  
      result = rescale_filter.filter(env_response)[0]
      unfiltered_observation = env_response.next_state["observation"]
      filtered_observation = result.next_state["observation"]
  
      # make sure the original observation is unchanged
      assert unfiltered_observation.shape == (20, 30, 3)
  
      # validate the shape of the filtered observation
      assert filtered_observation.shape == (10, 15, 3)
  
      # make a grayscale observation bigger
      env_response = EnvResponse(
          next_state={"observation": np.ones([20, 30])},
          reward=0,
          game_over=False,
      )
      rescale_filter = InputFilter()
      rescale_filter.add_observation_filter(
          "observation",
          "rescale",
          ObservationRescaleSizeByFactorFilter(2),
      )
      result = rescale_filter.filter(env_response)[0]
      filtered_observation = result.next_state["observation"]
  
      # validate the shape of the filtered observation
      assert filtered_observation.shape == (40, 60)
      assert np.all(filtered_observation == np.ones([40, 60]))
  
file_path: coach/rl_coach/tests/filters/observation/test_observation_rescale_size_by_factor_filter.py
imports: import os
  import sys
  import pytest
  import numpy
  from rl_coach.filters.observation.observation_rescale_size_by_factor_filter import ObservationRescaleSizeByFactorFilter
  from rl_coach.spaces import ObservationSpace
  from rl_coach.core_types import EnvResponse
  from rl_coach.filters.filter import InputFilter
label_desc: Use image node_id 1 for calling a global function with example usage: test_filter() without return types