Luckily the same program serves, since for such models, the E count (expected count) of an item a can be found as a • g(a)/goal.
the inside-outside algorithm has the same structure as computing the function and its gradient.