You should not (never) use .data. The with torch.no_grad() is good here.
This looks good to me. Keep in mind though that if you use optimizers that have states (sgd with momentum, adam, etc) these states will persist from one inner loop to the other.