.eval() and .train() are not related to the gradient calculation and will just switch the behavior of some layers. E.g. dropout will be disabled and batch norm layers will use their internal running estimates instead of the batch stats.
The warnings/errors regarding a cleared graph should not change if you switch between eval and train.