code: def test_record_stacking():
      r1 = _mock_structured_spaces_record(1)
      r2 = _mock_structured_spaces_record(2)
      r3 = _mock_structured_spaces_record(3, done=True)
  
      stacked = StructuredSpacesRecord.stack_records([r1, r2, r3])
  
      # Check that the observations are stacked as expected
  
      expected_observations = {
          0: dict(
              x=np.array([[10, 10], [20, 20], [30, 30]]),
              y=np.array([[10, 10], [20, 20], [30, 30]]),
          ),
          1: dict(z=np.array([[11], [21], [31]])),
      }
  
      for step_key in [0, 1]:
          for obs_key, exp_value in expected_observations[
              step_key
          ].items():
              assert np.all(
                  stacked.observations_dict[step_key][obs_key]
                  == exp_value
              )
  
      # Check a couple of other values
  
      assert np.all(stacked.rewards_dict[0] == [1, 2, 3])
      assert np.all(stacked.dones_dict[1] == [False, False, True])
      assert stacked.actions_dict[0]["action"].shape == (3, 2)
  
file_path: maze/maze/test/core/trajectory_recording/test_spaces_step_record.py
imports: from typing import List, Union
  import numpy
  import torch
  from maze.core.env.structured_env import ActorID
  from maze.core.trajectory_recording.records.spaces_record import SpacesRecord
  from maze.core.trajectory_recording.records.structured_spaces_record import StructuredSpacesRecord
label_desc: Use image node_id 3 for calling a global function with example usage: test_record_stacking() without return types