How to convert optional<Tensor> to Tensor

I’m writing a custom op for TorchScript, and the c++ function is like

at::Tensor myforward(const at::Tensor& input0,  // input
                           const at::Tensor& input1,  // weight
                           const optional<Tensor>& input2,  // bias

because the bias may be None in python, and how to convert the optional to Tensor?
I tried input2.value_or(Tensor{}) but couldn’t be compiled.

You can dereference it (*input2) if it .has_value() is true).
As far as I can tell, these type of utility interfaces usually designed to be compatible with the usual (here std::optional, interfaces) but is duplicated to avoid implementation quirks with older (?) c++ compilers.

Best regards

Thomas