How does NoGradGuard works in Cpp?

This is more a conceptual question… Consider:

NoGradGuard guard;
b -= lr * b.grad();

I know that NoGradGuard will disable action recording for the next gradient calculation.
But how does it really works?