code: def flat_structured_shapes(
      shapes: Dict[StepKeyType, Dict[str, Sequence[int]]]
  ) -> Dict[str, Sequence[int]]:
      """Flatten a dict of shape dicts to a single dict
  
      :param shapes: Collection of shape dict.
      :return: Flat shape dict.
      """
      result = dict()
  
      for sub_step_key, sub_step_space in shapes.items():
          for key, action_space in sub_step_space.items():
              # check if the heads match
              if key in result:
                  assert result[key] == action_space
  
              result[key] = action_space
  
      return result
  
imports: from typing import Dict, Union, Sequence
  from gym import spaces
  from maze.core.env.structured_env import StepKeyType
label_desc: Use image node_id 2 for calling a global function with example usage: flat_structured_shapes(shapes) and returns: result