code: def validate_observation_statistics(
      statistics: dict, validation_callback: Callable
  ):
      """
      Computes statistics for gathered observations.
      :param statistics: Gathered observations.
      :param validation_callback: Callback for statistical measures to perform on every leaf in the observation space
      tree. Structure: measure name -> Callable.
      """
  
      def process_key(_key: Any):
          """
          Processes current observation subspace.
          :param _key: Key to current observation subspace.
          """
          # Check whether we are in the last leaf.
          if "min" in statistics[_key] and isinstance(
              statistics[_key]["min"], np.ndarray
          ):
              # Compute statistics.
              statistics[_key]["min"] = np.min(
                  np.asarray(statistics[_key]["values"])
              )
              statistics[_key]["max"] = np.max(
                  np.asarray(statistics[_key]["values"])
              )
              statistics[_key]["interval"] = (
                  statistics[_key]["max"] - statistics[_key]["min"]
              )
              statistics[_key].pop("values")
  
              # Execute validation callbacks.
              assert validation_callback(
                  statistics[_key]
              ), "Validation callback failed."
          else:
              validate_observation_statistics(
                  statistics[_key], validation_callback
              )
  
      if isinstance(statistics, dict):
          for key in statistics:
              process_key(key)
      elif isinstance(statistics, tuple):
          for i, _ in enumerate(statistics):
              process_key(i)
  
imports: from typing import Any, Callable, Iterable
  import gym
  import numpy
  from maze.core.wrappers.observation_normalization.observation_normalization_wrapper import ObservationNormalizationWrapper
label_desc: Use image node_id 2 for calling a global function with example usage: validate_observation_statistics(statistics, validation_callback) without return types