torch.onnx.export does not return anything, thus will yield an error, if you try to access the return value.
In your code snippet, you are using torch.onnx._export (note the underscore), which seems to be an internal method, and will yield an output.
I’m not sure, which method you are currently using.