This is only a problem if the original Tensor requires gradients when you modify it and you do so in a differentiable way.
In general, you can use the torch::NoGradGuard guard; to disable gradients in the local scope. You can use that to prevent any issue while you initialize a Tensor.
That being said, in the code above, it seems like your original Tensor does not require gradients so it might not be the place?