class_docstr: Basically a list of TimeSteps with convenience methods.
class_docstr_tok: ["Basically","a","list","of","TimeSteps","with","convenience","methods","."]
docstr: Truncate trajectories, keeping the last `num_to_keep` time-steps.
code: def truncate(self, num_to_keep=1):
      """Truncate trajectories, keeping the last `num_to_keep` time-steps."""
  
      # We return `ts_copy` back to the truncator.
      ts_copy = self._time_steps[:]
  
      # We keep the last few observations.
      self._time_steps = self._time_steps[-num_to_keep:]
  
      # NOTE: We will need to set the rewards to 0, to eliminate double counting.
      for i in range(self.num_time_steps):
          self._time_steps[i] = self._time_steps[i].replace(
              raw_reward=0, processed_reward=0
          )
  
      return Trajectory(time_steps=ts_copy)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import os
  import pickle
  import re
  import sys
  import time
  from absl import logging
  import cloudpickle
  import numpy
  from tensor2tensor.envs import time_step
  import tensorflow.compat.v1
label_desc: Use image node_id 5 for calling the Trajectory obj's underlying member method code with example usage: obj.truncate(num_to_keep) and returns: Trajectory