Confusion relative to derivative of partition function I have this partition function

Now if I take the derivative of log(Z(x)) wrt $\lambda_k$
the result is 

I didn't get how this was derived. This is the paper 
 A: Write $\mathbf{x} = \mathbf{x}^{(i)}$ just to avoid writing superscript $(i)$'s everywhere.
$$\frac{\partial}{\partial \lambda_k} \log Z(\mathbf{x}) = \frac{1}{Z(\mathbf{x})} \frac{\partial}{\partial \lambda_k} Z(\mathbf{x}) = \frac{1}{Z(\mathbf{x})} \sum_\mathbf{y} \frac{\partial}{\partial \lambda_k} \exp\left(\sum_{j=1}^K \lambda_j f_j(y_t, y_{t-1}, \mathbf{x}_t)\right)$$
which, using the ordinary chain rule for functions of one variable, gives
$$\frac{1}{Z(\mathbf{x})} \sum_\mathbf{y} f_k(y_t, y_{t-1}, \mathbf{x}_t) \exp\left(\sum_{j=1}^K \lambda_j f_j(y_t, y_{t-1}, \mathbf{x}_t)\right) = \sum_\mathbf{y}f_k(y_t, y_{t-1}, \mathbf{x}_t) \frac{\exp\left(\sum_{j=1}^K \lambda_j f_j(y_t, y_{t-1}, \mathbf{x}_t)\right)}{Z(\mathbf{x})} $$
By the definition of $p(\mathbf{y}|\mathbf{x})$ in Equation 1.16 of the paper, this is
$$\sum_\mathbf{y} f_k(y_t, y_{t-1}, \mathbf{x}_t) p(\mathbf{y}|\mathbf{x}).$$
Now $\mathbf{y}$ is shorthand for $(y,y')$ and the sum over all possible $\mathbf{y}$ has been rewritten as $\sum_{y, y'}$.
