Are they equivalent?
a = ...
loss1 = net(a)

b = ...
loss2 = net(b)

c = loss1+loss2
c.backward()
optimizer.step()

a = ...
loss1 = net(a)
loss1.backward()

b = ...
loss2 = net(b)
loss2.backward()
optimizer.step()