x = torch.tensor(3.0, requires_grad=True) with torch.no_grad(): y = x ** 2 print(y.requires_grad) # False