added backward computation
training SPN