First, you taught me that forward can output 2 output items which I wasn’t aware.
My intuition, based on what you showed me, would be:
res1, res2 = net(input)
loss1 = criterion(res1, target)
loss2 = criterion(res2, target)
loss1.backward()
loss2.backward()
hNetOptimizer1.step()
hNetOptimizer2.step()

Namely, I would like to have 2 optimizer.
One updates the A1 block according to output of B1 and another updated A1, A2 according to B2.
Does it make any sense?