Hi @tom!
I’m a bit of a late reader on this, but I find myself in a situation in which I need to try retain_graph=true.
Trying out your suggestion, I get an error like the following, which I don’t really understand:
error: no viable conversion from 'const c10::nullopt_t' to 'const at::Tensor'
loss.backward(torch::nullopt, true, false);

Do you happen to know why this happens?