Mixed Membership Stochastic Block Models Implementation

I want to implement MMSB Model for which I am following the paper https://arxiv.org/abs/0705.4485

The model is described as image
User data is the observed data matrix with 20 rows and 20 columns capturing the relation between all nodes.

(people,val) = user_data.shape
user_data_vector = user_data.reshape(people*people,1).T
#Number of communities
K = 3
alpha = np.ones((1,K))
model = pm.Model()

B = np.eye(K)*0.8 #interaction between different communities
with model:
    pi_list = np.empty(people,dtype=object)
    for user in range(people):
        user_pi = pm.Dirichlet('userx_pi_%d' % user, a=alpha, shape = (1,K))
        pi_list[user] = user_pi

    z_aTb = np.empty([people,people],dtype=object)
    z_bTa = np.empty([people,people],dtype=object)
    bernoulli_params = np.empty([people,people],dtype=object)
    #y = np.empty([people,people],dtype=object)
    for a_person in range(people):
        for b_person in range(people):
            z_aTb[a_person,b_person] = pm.Categorical('ax_%dT%d' %(a_person,b_person),p = pi_list[a_person], shape =(1,K))
            z_bTa[b_person,a_person] = pm.Categorical('bx_%dT%d' %(b_person,a_person),p = pi_list[b_person], shape = (1,K))
            bernoulli_params[a_person,b_person] = np.dot(np.dot(z_aTb[a_person,b_person],B),z_bTa[b_person,a_person].T) 
            #bernoulli_params[a_person,b_person] = tt.dot(z_aTb[a_person,b_person],B) 
            #y[a_person,b_person] = pm.Bernoulli('y%d%d' %(a_person,b_person), p=bernoulli_params[a_person,b_person] , observed = user_data[a_person,b_person])
    bernoulli_params = bernoulli_params.reshape(1,people*people) 
with model:
    `y = pm.Bernoulli('y', p=bernoulli_params , observed = user_data_vector)`   

I am providing the likelihood based on the bernoulli distribution with p being derived as described in the model. I also reshaped it in such a way that each data point relational links are ordered sequentially such that the first data points link then the second and so on.

But I am getting an error

raise AsTensorError(“Cannot convert %s to TensorType” % str_x, type(x)) for line
y = pm.Bernoulli('y', p=bernoulli_params , observed = user_data_vector) . I checked for the shapes of both p and observed they are correct but I am not really sure why it is giving me such an error.
I also tried thenao.tensor.dot for numpy.dot but i am getting same error . Also tried to use reshape with theano but none worked.

Please help me with this.
Thanks in advance.