Solution (source code)

= Solution

For each $i$, place $\xi_i$ and $\eta_i$ inside a plate replicated $N$ times. The directed edges are represented by
$$
(\mu,\tau^2)\longrightarrow\xi_i\longrightarrow x_i,
\qquad
(\alpha,\beta,\sigma^2,\xi_i)\longrightarrow\eta_i\longrightarrow y_i.
$$
The shaded observed nodes are $x_i,y_i$; the unshaded nodes $\xi_i,\eta_i$ are latent; and $\alpha,\beta,\sigma^2,\mu,\tau^2$ lie outside the plate. This is the <probabilistic graphical model> encoded by the joint factorization.