Thanks for the explanation. So, if I add torch::autograd::GradMode::set_enabled(true); after the operation, does it activate the gradient accumulation?

{
torch::autograd::GradMode::set_enabled(false);  // This is a global setting
t.add_(1);  // Does not accumulate gradient
torch::autograd::GradMode::set_enabled(true);
}