Revert "Revert "Torch: only write to sysfs if not already on""

This reverts commit f97fcec90aceff4e039f9b65875d474555f36a54.