def METHOD_NAME(shape, nboxes_per_img, sampling_ratio, device, box_size="large"):
    N, _, H, _ = shape
    input = torch.rand(*shape)
    boxes = []
    batch_idx = []
    for k in range(N):
        if box_size == "large":
            b = random_boxes([80, 80, 130, 130], 24, nboxes_per_img, H)
        else:
            b = random_boxes([100, 100, 110, 110], 4, nboxes_per_img, H)
        boxes.append(b)
        batch_idx.append(torch.zeros(nboxes_per_img, 1, dtype=torch.float32) + k)
    boxes = torch.cat(boxes, axis=0)
    batch_idx = torch.cat(batch_idx, axis=0)
    boxes = torch.cat([batch_idx, boxes], axis=1)
    input = input.to(device=device)
    boxes = boxes.to(device=device)
    def bench():
        if False and sampling_ratio > 0 and N == 1:
            # enable to benchmark grid_sample (slower)
            grid_sample_roi_align(input, boxes[:, 1:], 7, 1.0, sampling_ratio)
        else:
            roi_align(input, boxes, 7, 1.0, sampling_ratio, True)
        if device == "cuda":
            torch.cuda.synchronize()
    return bench