The computation graph is created in each new forward pass. Because weights isn’t used in your second loop, the computation graph won’t include it at all.
If you want to use weight somehow, you would need to add it to the computation for the loss calculation.