fix usage of autodiff macro with inner functions
#138314
Merged
autodiff macro with inner functions
#138314