hi, recently I am reading the pytorch C++ source code, in the file engine.cpp we could see the c++ engine instance which runs the backwards.
the author explains the Reentrant backwards by using the scenario of  “suppose that you call backward() inside of a worker thread.”
but i would not image such scenario under any condition.
usually the following code would do backwards grad computation. the call stack is like this:y.backward()->THPEngine_run_backward->Engine::execute()->thread_main(). the work thread would do the compute work.
the author says in the work thread during the backwards,we call backward() again,which is the nested.
so in this case, what should my python code look like? I don’t know how to trigger such scenario in python level. even don’t know how to call backward() inside of a worker thread.
maybe Reentrant backwards is designed for extensibility?
x=Variable(torch.Tensor([10]),requires_grad=True)
y=x*5
y.backward()