def get_frame(self, idx, history_length=<NUM_LIT:1>):
if idx >= self.current_size:<EOL><INDENT>raise VelException("<STR_LIT>")<EOL><DEDENT>if history_length > <NUM_LIT:1>:<EOL><INDENT>assert self.state_buffer.shape[-<NUM_LIT:1>] == <NUM_LIT:1>,"<STR_LIT>"<EOL><DEDENT>accumulator = []<EOL>last_frame = self.state_buffer[idx]<EOL>accumulator.append(last_frame)<EOL>for i in range(history_length - <NUM_LIT:1>):<EOL><INDENT>prev_idx = (idx - <NUM_LIT:1>) % self.buffer_capacity<EOL>if prev_idx == self.current_idx:<EOL><INDENT>raise VelException("<STR_LIT>")<EOL><DEDENT>elif self.dones_buffer[prev_idx]:<EOL><INDENT>accumulator.append(np.zeros_like(last_frame))<EOL><DEDENT>else:<EOL><INDENT>idx = prev_idx<EOL>accumulator.append(self.state_buffer[idx])<EOL><DEDENT><DEDENT>return np.concatenate(accumulator[::-<NUM_LIT:1>], axis=-<NUM_LIT:1>)<EOL>
Return frame from the buffer