def METHOD_NAME(ctx, base_anchors, feat_h, feat_w, stride_h: int,
            stride_w: int):
    """Generate grid priors by base anchors."""
    # torch>=1.13 has runtime error
    # when using torch.arange in autograd function
    output = getattr(GridPriorsTRTOp, 'output', None)
    if output is not None:
        return output
    device = base_anchors.device
    dtype = base_anchors.dtype
    shift_x = torch.arange(0, feat_w, device=device).to(dtype) * stride_w
    shift_y = torch.arange(0, feat_h, device=device).to(dtype) * stride_h
    def _meshgrid(x, y, row_major=True):
        # use shape instead of len to keep tracing while exporting to onnx
        xx = x.repeat(y.shape[0])
        yy = y.view(-1, 1).repeat(1, x.shape[0]).view(-1)
        if row_major:
            return xx, yy
        else:
            return yy, xx
    shift_xx, shift_yy = _meshgrid(shift_x, shift_y)
    shifts = torch.stack([shift_xx, shift_yy, shift_xx, shift_yy], dim=-1)
    all_anchors = base_anchors[None, :, :] + shifts[:, None, :]
    all_anchors = all_anchors.view(-1, 4)
    # then (0, 1), (0, 2), ...
    return all_anchors