The only factor affected by the expectation constraints is q(z).
recall from the previous section that the update for q(z) is performed via gradient search on the dual of a constrained minimization problem of the form: we first compute the update for q (z): where N is the total number of sentences, len(n) is the length of sentence n, and index h(nj) refers to the head of the jth node of sentence n. Given this q (z) a gradient search is performed using (6) to find the optimal λ and thus the primal solution for updating q(z).