How to implement the addtion of grad in the backback-propagating,how to add extra term (which is the gradient to middle net layer output) to the network

this is my new progress! can u give me some advice … , MAY THE FORCE BE WITH YOU!