Checking whether requires_grad is True or False

Hi all,
How can I check whether rquires_grad of a variable is True or False?. Can I set the requires_grad by x.requires_grad=True? (x is a variable).

Thanks in advance

1 Like

You can check with print(x.requires_grad)

You can set it with x.requires_grad_(true):