code: def match_observation_space_structure(
      space_a: Iterable, space_b: Iterable
  ) -> bool:
      """
      Checks whether structure and shapes in space_a match those in space_b.
      :param space_a: First space.
      :param space_b: Second space.
      :return: True if shapes match, False if shape don't match or structure diverges.
      """
  
      # Check both spaces are of the same type.
      if not type(space_a) == type(space_b):
          return False
  
      # If observation space is a Dict: Examine sub-spaces recursively.
      if isinstance(space_a, dict) and isinstance(space_b, dict):
          if not space_a.keys() == space_b.keys():
              return False
          for key in space_a:
              if not match_observation_space_structure(
                  space_a[key], space_b[key]
              ):
                  return False
  
      # If observation space is a Tuple: Update sub-spaces recursively.
      elif isinstance(space_a, tuple) and isinstance(space_b, tuple):
          if not len(space_a) == len(space_b):
              return False
  
          for subspace_a, subspace_b in zip(space_a, space_b):
              if not match_observation_space_structure(
                  subspace_a, subspace_b
              ):
                  return False
  
      elif isinstance(space_a, np.ndarray) and isinstance(
          space_b, np.ndarray
      ):
          if not space_a.shape == space_b.shape:
              return False
  
      # Note that we only consider three possible datatypes here: dict (equivalent to gym.spaces.Dict), tuple
      # (equivalent to gym.spaces.Tuple) and numerical numpy.ndarray (equivalent to gym.spaces.Box).
      # Other datatypes are only checked in terms of type equality.
  
      return True
  
file_path: maze/maze/test/shared_test_utils/observation_normalization.py
imports: from functools import partial
  from typing import Dict, Callable, Iterable
  import gym
  import numpy
  from maze.core.env.maze_env import CoreEnvType
  from maze.core.env.structured_env import StructuredEnv
  from maze.core.utils.factory import ConfigType
  from maze.core.wrappers.observation_normalization.observation_normalization_wrapper import ObservationNormalizationWrapper
label_desc: Use image node_id 3 for calling a global function with example usage: match_observation_space_structure(space_a, space_b) and returns: True, False, False, False, False, False, False