fix for reshaping in jacobian_apply