class_docstr: Holds structured spaces records (i.e., raw actions and observations recorded during a rollout). 
docstr: Convenience method for calculating the total reward of a given trajectory.
docstr_tok: ["Convenience","method","for","calculating","the","total","reward","of","a","given","trajectory","."]
code: def total_reward(self):
      """Convenience method for calculating the total reward of a given trajectory."""
      if len(self) == 0:
          return 0
  
      assert not self.step_records[
          -1
      ].is_batched(), (
          "cannot determine total reward for a batched trajectory."
      )
      total_reward = 0
      for record in self.step_records:
          total_reward += sum(record.rewards_dict.values())
      return total_reward
  
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 6 for calling the SpacesTrajectoryRecord obj's underlying member method code with example usage: obj.total_reward() and returns: total_reward, int