The linear count expectations can be computed efficiently by the forward-backward recurrence for HMMs.
we have to design new algorithms for quadratic count expectations which will be done in the rest of this section.