Creating Within Cluster Correlation Matrix

Hi everyone,

I am trying to code a model where I want to put a multivariate gaussian prior where observations that come from different clusters are independent, but are correlated to observations within the same cluster. What do you think is the best way of coding it?

Note that clusters have different number of observations, ideally I would like some code where the input would be a vector of cluster IDs. The variance component is imputed from the data so it is not necessary to model. The prior would be the following:

\begin{pmatrix} Y_0 \\ \ \vdots \\ Y_K \end{pmatrix} \sim \mathcal{MN} \left( \boldsymbol{m}, \begin{pmatrix} A_{1} & \cdots & 0 \\ & \ddots & \\ 0 & \cdots & A_{K} \end{pmatrix} \right)

Where (A_k)_{k=1}^{K} are the block matrices, potentially of different dimensions that represent the within clusters correlation parameters.

Thanks in advance for the help.