class_docstr: Base class for processing individual trajectories.
class_docstr_tok: ["Base","class","for","processing","individual","trajectories","."]
docstr: Convert an episode trajectory record into an array of observations and actions using the given env.
  
  :param trajectory: Episode record to load
  :param conversion_env: Env to use for conversion of MazeStates and MazeActions into observations and actions.
                         Required only if state records are being loaded (i.e. conversion to raw actions and
                         observations is needed).
  :return: Loaded observations and actions. I.e., a tuple (observation_list, action_list). Each of the
           lists contains observation/action dictionaries, with keys corresponding to IDs of structured
           sub-steps. (I.e., the dictionary will have just one entry for non-structured scenarios.)
docstr_tok: ["Convert","an","episode","trajectory","record","into","an","array","of","observations","and","actions","using","the","given","env",".",":","param","trajectory",":","Episode","record","to","load",":","param","conversion_env",":","Env","to","use","for","conversion","of","MazeStates","and","MazeActions","into","observations","and","actions",".","Required","only","if","state","records","are","being","loaded","(","i.e",".","conversion","to","raw","actions","and","observations","is","needed",")",".",":","return",":","Loaded","observations","and","actions",".","I.e.",",","a","tuple","(","observation_list",",","action_list",")",".","Each","of","the","lists","contains","observation\/action","dictionaries",",","with","keys","corresponding","to","IDs","of","structured","sub-steps",".","(","I.e.",",","the","dictionary","will","have","just","one","entry","for","non-structured","scenarios",".",")"]
code: def convert_trajectory_with_env(
      trajectory: TrajectoryRecord, conversion_env: Optional[MazeEnv]
  ) -> List[StructuredSpacesRecord]:
      """Convert an episode trajectory record into an array of observations and actions using the given env.
  
      :param trajectory: Episode record to load
      :param conversion_env: Env to use for conversion of MazeStates and MazeActions into observations and actions.
                             Required only if state records are being loaded (i.e. conversion to raw actions and
                             observations is needed).
      :return: Loaded observations and actions. I.e., a tuple (observation_list, action_list). Each of the
               lists contains observation/action dictionaries, with keys corresponding to IDs of structured
               sub-steps. (I.e., the dictionary will have just one entry for non-structured scenarios.)
      """
      step_records = []
  
      for step_id, step_record in enumerate(trajectory.step_records):
          # Process and convert in case we are dealing with state records (otherwise no conversion needed)
          if isinstance(step_record, StateRecord):
              assert conversion_env is not None, (
                  "when conversion from Maze states is needed, conversion env "
                  "needs to be present."
              )
  
              # Drop incomplete records (e.g. at the end of episode)
              if (
                  step_record.maze_state is None
                  or step_record.maze_action is None
              ):
                  continue
              # Convert to spaces
              step_record = StructuredSpacesRecord.converted_from(
                  step_record,
                  conversion_env=conversion_env,
                  first_step_in_episode=step_id == 0,
              )
  
          step_records.append(step_record)
  
      return step_records
  
imports: import dataclasses
  from abc import abstractmethod
  from typing import List, Optional, Union, Dict, Tuple
  from maze.core.annotations import override
  from maze.core.env.maze_env import MazeEnv
  from maze.core.trajectory_recording.records.state_record import StateRecord
  from maze.core.trajectory_recording.records.structured_spaces_record import StructuredSpacesRecord
  from maze.core.trajectory_recording.records.trajectory_record import TrajectoryRecord
label_desc: Use image node_id 2 for calling the TrajectoryProcessor obj's underlying member method code with example usage: obj.convert_trajectory_with_env(trajectory, conversion_env) and returns: step_records