code: def _complete_trajectory(self, trajectory, index):
      
  
      assert isinstance(trajectory, Trajectory)
  
      # This *should* be the case.
      assert trajectory.last_time_step.action is None
  
      # Add to completed trajectories.
      self._completed_trajectories.append(trajectory)
  
      # Make a new one to replace it.
      self._trajectories[index] = Trajectory()
docs: Completes the given trajectory at the given index.