fixed log_sum_exp so it works with higher order autodiff and added tests