class_docstr: Defines an abstract observation preprocessor function.
  
  Attributes:
      shape (List[int]): Shape of the preprocessed output.
docstr: Checks the shape of the given observation.
docstr_tok: ["Checks","the","shape","of","the","given","observation","."]
code: def check_shape(self, observation: Any) -> None:
      """Checks the shape of the given observation."""
      if self._i % OBS_VALIDATION_INTERVAL == 0:
          # Convert lists to np.ndarrays.
          if type(observation) is list and isinstance(
              self._obs_space, gym.spaces.Box
          ):
              observation = np.array(observation).astype(np.float32)
          if not self._obs_space.contains(observation):
              observation = convert_element_to_space_type(
                  observation, self._obs_for_type_matching
              )
          try:
              if not self._obs_space.contains(observation):
                  raise ValueError(
                      "Observation ({} dtype={}) outside given space ({})!".format(
                          observation,
                          observation.dtype
                          if isinstance(self._obs_space, gym.spaces.Box)
                          else None,
                          self._obs_space,
                      )
                  )
          except AttributeError as e:
              raise ValueError(
                  "Observation for a Box/MultiBinary/MultiDiscrete space "
                  "should be an np.array, not a Python list.",
                  observation,
              ) from e
      self._i += 1
  
imports: from collections import OrderedDict
  import logging
  import numpy
  import gymnasium
  from typing import Any, List
  from ray.rllib.utils.annotations import override, PublicAPI, DeveloperAPI
  from ray.rllib.utils.spaces.repeated import Repeated
  from ray.rllib.utils.typing import TensorType
  from ray.rllib.utils.images import resize
  from ray.rllib.utils.spaces.space_utils import convert_element_to_space_type
label_desc: Use image node_id 5 for calling the Preprocessor obj's underlying member method code with example usage: obj.check_shape(observation) without return types