fixed bug in initialize_residual that occurred when inputs passed to check_gradient are not tuples.