Revert "Simplify _use_grad_for_differentiable (#98706)"
This reverts commit b9da79d2800c2ca00b57bc3ac86b43e01be174b6.
Reverted https://github.com/pytorch/pytorch/pull/98706 on behalf of https://github.com/huydhn due to Sorry for reverting your PR but a bunch of inductor tests are failing after this commit, so reverting the PR just to be sure