By conjugacy of the beta to the Bernoulli process we can compute \(q(\pi ) \triangleq p(\pi \mid z)\)  analytically. In addition, to make inference scalable, we employ stochastic inference for \(\pi _k\)  and use natural gradient of the posterior parameters \((a_k , b_k)\)  using random batch of data \(S \subset \lbrace x_n\rbrace _{n=1}^{N}\) to update the posterior parameters , where \(\eta \)  is the stochastic gradient step [1]}:
\(q(\pi ) = \textstyle \prod \nolimits _{k} \mathrm {Beta}(\pi _k \mid a_k, b_k); \quad &a_k^{\prime } = \alpha \textstyle \frac{\gamma }{K} + \frac{N}{|S|}\sum \nolimits _{n \in S} z_{nk} \ ; b_k^{\prime } = \alpha \left(1-\frac{\gamma }{K}\right) + \frac{N}{|S|} \sum _{n \in S}\left(1-z_{nk}\right) \\&a_k \leftarrow (1-\eta ) a_k + \eta \ a_k^{\prime } \ \ \quad ;b_k \leftarrow (1-\eta ) b_k + \eta \ b_k^{\prime } {} \) 
