Return batch with given indexes

def get_transitions(self, indexes, history_length=1):
        """ Return batch with given indexes """
        frame_batch_shape = (
                [indexes.shape[0]]
                + list(self.state_buffer.shape[1:-1])
                + [self.state_buffer.shape[-1] * history_length]
        )

        past_frame_buffer = np.zeros(frame_batch_shape, dtype=self.state_buffer.dtype)
        future_frame_buffer = np.zeros(frame_batch_shape, dtype=self.state_buffer.dtype)

        for buffer_idx, frame_idx in enumerate(indexes):
            past_frame_buffer[buffer_idx], future_frame_buffer[buffer_idx] = self.get_frame_with_future(
                frame_idx, history_length
            )

        actions = self.action_buffer[indexes]
        rewards = self.reward_buffer[indexes]
        dones = self.dones_buffer[indexes]

        data_dict = {
            'observations': past_frame_buffer,
            'actions': actions,
            'rewards': rewards,
            'observations_next': future_frame_buffer,
            'dones': dones,
        }

        for name in self.extra_data:
            data_dict[name] = self.extra_data[name][indexes]

        return data_dict