You won’t be able to assign values to tensors, if they are needed to compute the gradient.
In your case it seems that f1 is indeed needed in the backward pass to compute some gradients, so that manipulating it inplace is disallowed.
This short example demonstrates the issue:
w1 = nn.Parameter(torch.randn(1))
w2 = nn.Parameter(torch.randn(1))
x = torch.randn(1)

y = w1 * x
out = y * w2
#y[0] = 1.
out.mean().backward()

print(w2.grad, y)

Here you can see, that y is needed to compute the gradient for w2.
If you try to manipulate it after its usage (uncomment the assignment), an error will be raised:
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [1]], which is output 0 of MulBackward0, is at version 1; expected version 0 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).