Note that the right way to update the weight is with:
with torch.no_grad():
    W -= outer_loss_wrt_W * 0.01

.data should not be used anymore!
Your code looks good at first glance. What is the issue that you have with it?