Some thoughts:
Don’t use .data these days! It’s bad for you, really! with torch.no_grad(): will do fine.
In fact, you probably should copy back the original values between the backward and the step. For a reasonably complicated model (more than one layer), your gradients might be off from this and if you had stayed clear of using .data PyTorch would have told you.
You multiply with 1- drop_prob, which seems unusual.
The convenience of a wrapper: In any single instance is easily done manually, but now you would want to apply this to some weights rather than all. Is it still as straightforward?
The safety of a wrapper: Having a well-tested wrapper saves you from implementation mistakes. (See above.)
Best regards
Thomas