Break up _infer_function_def
Add back checking of function signature