code: def sample_batch_trajectories(self, rollout_length, history_length):
          
          # Sample from up to total size
          if self.current_size < self.buffer_capacity:
              if rollout_length + 1 > self.current_size:
                  raise VelException("Not enough elements in the buffer to sample the rollout")
  
              # -1 because we cannot take the last one
              return np.random.choice(self.current_size - rollout_length) + rollout_length - 1
          else:
              if rollout_length + history_length > self.current_size:
                  raise VelException("Not enough elements in the buffer to sample the rollout")
  
              candidate = np.random.choice(self.buffer_capacity)
  
              # These are the elements we cannot draw, as then we don't have enough history
              forbidden_ones = (
                      np.arange(self.current_idx, self.current_idx + history_length + rollout_length - 1)
                      % self.buffer_capacity
              )
  
              # Exclude these frames for learning as they may have some part of history overwritten
              while candidate in forbidden_ones:
                  candidate = np.random.choice(self.buffer_capacity)
  
              return candidate
docs: Return indexes of next sample