The Gradient of Algebraic Model Counting