I am using pytorch 1.6.0 and my cpp code is like
void fit(const at::Tensor & x, const at::Tensor & y, const at::Tensor & w){
   if(w.defined()){
   
   }else{
  
   }
}

and the python binding code (using pybind11) is like
m.def("fit", &fit, py::arg("x"), py::arg("y"), py::arg("w")=py::none())

The compiling is fine. However,  I failed to call it in python using fit(x, y)  or fit(x,y, None).
The error is
TypeError: fit(): incompatible function arguments.
thanks.