code: def get_frame(self, idx, history_length=1):
          
          if idx >= self.current_size:
              raise VelException("Requested frame beyond the size of the buffer")
  
          if history_length > 1:
              assert self.state_buffer.shape[-1] == 1, \
                  "State buffer must have last dimension of 1 if we want frame history"
  
          accumulator = []
  
          last_frame = self.state_buffer[idx]
          accumulator.append(last_frame)
  
          for i in range(history_length - 1):
              prev_idx = (idx - 1) % self.buffer_capacity
  
              if prev_idx == self.current_idx:
                  raise VelException("Cannot provide enough history for the frame")
              elif self.dones_buffer[prev_idx]:
                  # If previous frame was done - just append zeroes
                  accumulator.append(np.zeros_like(last_frame))
              else:
                  idx = prev_idx
                  accumulator.append(self.state_buffer[idx])
  
          # We're pushing the elements in reverse order
          return np.concatenate(accumulator[::-1], axis=-1)
docs: Return frame from the buffer