'Function to perform bprop of ROIPooling.
Arguments:
I (Tensor): input errors (C, pooled_height, pooled_width, roi_count)
argmax (Tensor): max args from the fprp (C, pooled_height, pooled_width, roi_count)
rois (Tensor): (ROIs, 5)
O (Tensor): output deltas (C, H, W, N)'

def roipooling_bprop(self, I, rois, O, argmax, roi_count, fm_channel, fm_height, fm_width, pooled_height, pooled_width, spatial_scale):

    thread = 1024
    assert (roi_count == rois.shape[0])
    count = (((fm_channel * fm_height) * fm_width) * self.bsz)
    assert (count == O.size)
    assert (argmax.dtype == np.int32)
    def get_blocks(N, thread):
        return (((N + thread) - 1) // thread)
    layer_dtype = I.dtype
    kernel = roipooling.map_string2func('bprop_roipooling', layer_dtype.str[1:])
    params = [(get_blocks(count, thread), 1, 1), (thread, 1, 1), self.stream, count, roi_count, self.bsz, fm_channel, fm_height, fm_width, pooled_height, pooled_width, I.gpudata, rois.gpudata, O.gpudata, argmax.gpudata, spatial_scale]
    kernel.prepared_async_call(*params)
