Hi
Just to give a small precision of why this happens.
When you do:
with torch.no_grad():
    y = x.view(2, 2)

What the no_grad block does is to not consider the operations inside as autograd ops. If you do an out of place operation in it, the result won’t require gradients because the operation that created it is not considered. Now if you return a view to an existing Tensor that itself requires gradient. Even though you ignore ops inside the block, the original Tensor requires gradients and since y here is just a view into it, it also requires gradients.
If you want to detach a Tensor from the computational graph, you can use as suggested above .detach(). I would advise to do the view first btw: y = x.view(2, 2).detach().