class_docstr: Implementation of the dead-end-clipping preprocessor. That is for each trajectory the last k states should be
  clipped iff the env is done in the last state.
class_docstr_tok: ["Implementation","of","the","dead-end-clipping","preprocessor",".","That","is","for","each","trajectory","the","last","k","states","should","be","clipped","iff","the","env","is","done","in","the","last","state","."]
docstr: Implementation of :class:`~maze.core.trajectory_recording.datasets.trajectory_processor.TrajectoryProcessor` interface.
          
docstr_tok: ["Implementation","of",":","class",":","`","~maze.core.trajectory_recording.datasets.trajectory_processor.TrajectoryProcessor","`","interface","."]
code: def pre_process(
      self, trajectory: TrajectoryRecord
  ) -> TrajectoryRecord:
      """Implementation of :class:`~maze.core.trajectory_recording.datasets.trajectory_processor.TrajectoryProcessor` interface."""
      is_done, info = self._retrieve_done_and_last_info(trajectory)
  
      # Check whether the given trajectory died due to a self inflicted mistake
      if is_done and (
          info is None or "TimeLimit.truncated" not in info
      ):
          # If the length of the trajectory is longer then the clip_k clip it, otherwise delete it.
          if len(trajectory) > self.clip_k:
              trajectory.step_records = trajectory.step_records[
                  : -self.clip_k
              ]
          else:
              trajectory.step_records = list()
  
      return trajectory
  
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 1 for calling the DeadEndClippingTrajectoryProcessor obj's underlying member method code with example usage: obj.pre_process(trajectory) and returns: trajectory