class_docstr: Holds structured spaces records (i.e., raw actions and observations recorded during a rollout). 
docstr: Stack multiple trajectories, keeping the time dimension intact.
  
  All the trajectories should be of the same length. The resulting trajectory will have the same number of steps,
  each being a stack of the corresponding steps of the input trajectories.
  
  :param trajectories: Trajectories to stack.
  :return: Trajectory record of the same lenght, consisting of stacked structured spaces records.
docstr_tok: ["Stack","multiple","trajectories",",","keeping","the","time","dimension","intact",".","All","the","trajectories","should","be","of","the","same","length",".","The","resulting","trajectory","will","have","the","same","number","of","steps",",","each","being","a","stack","of","the","corresponding","steps","of","the","input","trajectories",".",":","param","trajectories",":","Trajectories","to","stack",".",":","return",":","Trajectory","record","of","the","same","lenght",",","consisting","of","stacked","structured","spaces","records","."]
code: def stack_trajectories(
      cls, trajectories: List["SpacesTrajectoryRecord"]
  ) -> "SpacesTrajectoryRecord":
      """Stack multiple trajectories, keeping the time dimension intact.
  
      All the trajectories should be of the same length. The resulting trajectory will have the same number of steps,
      each being a stack of the corresponding steps of the input trajectories.
  
      :param trajectories: Trajectories to stack.
      :return: Trajectory record of the same lenght, consisting of stacked structured spaces records.
      """
      assert (
          len(set([len(t) for t in trajectories])) == 1
      ), "all trajectories must have the same length"
  
      stacked_trajectory = SpacesTrajectoryRecord(
          id=np.stack([trajectory.id for trajectory in trajectories])
      )
      step_records_in_time = list(
          zip(*[t.step_records for t in trajectories])
      )
      stacked_trajectory.step_records = [
          StructuredSpacesRecord.stack_records(list(recs))
          for recs in step_records_in_time
      ]
      return stacked_trajectory
  
imports: from typing import List, Optional, Any, TypeVar, Generic, Dict, Union
  import numpy
  from maze.core.env.action_conversion import ActionType, TorchActionType
  from maze.core.rendering.renderer import Renderer
  from maze.core.trajectory_recording.records.state_record import StateRecord
  from maze.core.trajectory_recording.records.structured_spaces_record import StructuredSpacesRecord, StepKeyType
label_desc: Use image node_id 2 for calling the SpacesTrajectoryRecord obj's underlying member method code with example usage: obj.stack_trajectories(cls, trajectories) and returns: stacked_trajectory