# Understanding Bayesian Hierarchical Model in Practice

I have a Bayesian hierarchical model with datapoints $$y_{ij}$$ which are samples from distributions with parameters $$\theta_j$$. For each distribution parameter $$\theta_j$$, there are $$n_j$$ datapoints generated. The distribution parameters themselves are independent samples from another distribution with parameter $$\psi$$. Both $$\theta=\{\theta_1,...,\theta_j\}$$ and $$\psi$$ are unobservable. I am trying to get the posterior distribution of $$\psi$$ given the datapoints $$y = \{y_{ij}\}\forall i,j$$.

I started with the basic Bayesian hierarchical model formula: $$P(\psi|y)\propto P(y|\psi)P(\psi)=P(\psi|y)\propto \sum_{\theta}P(y|\theta)P(\theta|\psi)P(\psi)$$ I understand that both $$y$$ and $$\theta$$ are vectors, therefore I have a few questions:

1. How to compute $$P(y|\theta)$$ since I only have $$P(y_{ij}|\theta_j)$$? I can compute $$P(y_j|\theta_j)=\prod_i P(y_{ij}|\theta_j)$$ but I don't think $$P(y|\theta)=\prod_j P(y_j|\theta_j)$$, right?
2. If $$\theta$$ is a vector of length $$n$$ (there are $$n$$ distributions generating datapoints) an state sapce size of each $$\theta_j$$ is 3, does the total number of available $$\theta$$ to be marginalized over be $$3^n$$? I am trying to figure out how many permutations of $$\theta$$ I need to sum over here, but I realize there is the exchangability condition which I am not sure if it has an effect on this or not.

Any help is deeply appreciated! Thanks!