I just faced the same problem, with the following MWE
A = torch.randn([5,5], requires_grad=True)
B = torch.zeros([2,2], requires_grad=True)
B[0,0] = A[0,0]
C=B.norm()
C.backward()

raising the error

RuntimeError: leaf variable has been moved into the graph interior

The issue may be resolved by setting requires_grad=False when initializing B. In another example, the same solution has been proposed: Leaf variable has been moved into the graph interior 178