How to pass a legal python value to at::OptionalIntArrayRef?

ruka: <p>Hi, I’m trying to write a custom conv backward function. This is what I’ve archived so far (I’ve delete extra code, just leave the basics)</p>
<pre><code class="lang-auto">class ConvFunction(torch.autograd.Function):
    @staticmethod
    def forward(ctx, input, weight, bias, stride, padding, dilation, groups, transposed=False, output_padding=[0]):
        
        ctx.save_for_backward(input, weight, bias)
        ctx.infos = {"stride": stride,
                     "padding": padding,
                     "dilation": dilation,
                     "transposed": transposed,
                     "output_padding": output_padding,
                     "groups": groups
                     }
        return cudnn_convolution.convolution(input, weight, bias,
                                             stride, padding, dilation, transposed,
                                             output_padding, groups)

    @staticmethod
    def backward(ctx, grad_output):
        input, weight, bias = ctx.saved_variables
        infos = ctx.infos
        input_grad = weight_grad = bias_grad = stride_grad = padding_grad = dilation_grad = groups_grad = None

        output_mask = [ctx.needs_input_grad[0],
                       ctx.needs_input_grad[1],
                       bias is not None and ctx.needs_input_grad[2],
                       ]

        input_grad, weight_grad, bias_grad = cudnn_convolution.convolution_backward(grad_output,
                                                                                    input,
                                                                                    weight,
                                                                                    None,  # &lt;--- Problem here, list and tuple not working either
                                                                                    infos["stride"],
                                                                                    infos["padding"],
                                                                                    infos["dilation"],
                                                                                    infos["transposed"],
                                                                                    infos["output_padding"],
                                                                                    infos["groups"],
                                                                                    output_mask)
return input_grad, weight_grad, bias_grad, stride_grad, padding_grad, dilation_grad, groups_grad
</code></pre>
<p>Following is the definition in my cpp file <strong>cudnn_convolution.cpp</strong></p>
<pre><code class="lang-auto">std::tuple&lt;at::Tensor, at::Tensor, at::Tensor&gt; convolution_backward(
    const at::Tensor&amp; grad_output_,
    const at::Tensor&amp; input_,
    const at::Tensor&amp; weight_,
    const at::OptionalIntArrayRef bias_sizes_opt,
    at::IntArrayRef stride,
    at::IntArrayRef padding,
    at::IntArrayRef dilation,
    bool transposed,
    at::IntArrayRef output_padding,
    int64_t groups,
    std::array&lt;bool, 3&gt; output_mask) {

    return at::convolution_backward(grad_output_,
				    input_,
				    weight_,
				    bias_sizes_opt
				    stride,
				    padding,
				    dilation,
				    transposed,
				    output_padding,
				    groups,
				    output_mask);
}

PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
   //skip convolution
    m.def("convolution_backward", &amp;convolution_backward, "convolution backward");
}
</code></pre>
<p>My error is:</p>
<blockquote>
<p>TypeError: convolution_backward(): incompatible function arguments. The following argument types are supported:<br>
1. (arg0: at::Tensor, arg1: at::Tensor, arg2: at::Tensor, arg3: c10::OptionalArrayRef, arg4: at::IntArrayRef, arg5: at::IntArrayRef, arg6: at::IntArrayRef, arg7: bool, arg8: at::IntArrayRef, arg9: int, arg10: List[bool[3]]) → Tuple[at::Tensor, at::Tensor, at::Tensor]</p>
</blockquote>
<p>I think the problem is the <strong>at::OptionalIntArrayRef</strong> type of <strong>bias_sizes_opt</strong>, what kind of variable in python should I pass to this type?</p>