Sorry I should have been clearer, a, b and c are not variables but each a group of operations (either a function or a nn.Module::forward). The point I was trying to make was that first I do operations where I want the gradient to be tracked (in a), then I do some where I don’t want them to be tracked (b), then I want them to be tracked again (c).
I’ll try and create a simple example tomorrow.