As long as you stick with PyTorch functions, you are fine.
What’s wrong with the first implementation?
If the backward pass doesn’t work, PyTorch will throw an error.
So if you don’t get an error, everything should be fine.