Solved by richard in post #5 
              
              
                .item() turns a Tensor into a Python number. Autograd can only keep track of computations on Tensors, so using the result of .item() effectively creates a new value that is not a part of the computation graph.