Solved by yoad.tewel in post #2 
              
              
                The derivative will compute with respect to both o1 and o2. 
Lets call d = o2 - o1. 
The derivative of o1 will be minus the gradient of the loss with respect to d, 
And the derivative  of o2 will be the gradient of the loss with respect to d.