Writing a customized likelihood for Mixed Membership Stochastic Model

Hi,

Given nature of dataset I am working on, I am planning to use ADVI for MMSB model. But due to the discrete RV I cant. So I was hoping if any one could guide me with how I can marginalize out the latent variables z_bsTuser and z_userTbs .
The model is as follows:

B = pm.Beta('Beta', a_0,b_0, shape = K)
user_community = pm.Dirichlet('user_comm', a = alpha, shape = (user_num,K))
bs_community = pm.Dirichlet('bs_community', a = alpha, shape = (bs_num,K))
z_bsTuser = pm.Categorical('btsTuser' ,p = user_community, shape =(bs_num,user_num))
z_userTbs = pm.Categorical('userTbts' ,p = bs_community, shape =(user_num,bs_num))
z_userTbs = z_userTbs.T
pD = tt.switch(tt.eq(z_userTbs,z_bsTuser), B[z_userTbs], eps)
#Likelihood
y = pm.Bernoulli( 'y',p = pD ,observed = user_bs_mat)

Help much appreicated!