PyMC3 AssertionError

I am new to PyMC3.
I am getting the following AssertionError while building my model:

AssertionError                            Traceback (most recent call last)
<ipython-input-32-01225e81bd32> in <module>()
    104         PREDICTED_Y[student][t][idx]  =pm.Bernoulli(y_name, p=yy[student][t][idx], observed=obsData)
    105   # sampling_end = time.time()
--> 106   trace = pm.sample(sample_num, tune=tune, chains=chains)

13 frames
/usr/local/lib/python3.7/dist-packages/theano/link/vm.py in make_vm(self, nodes, thunks, input_storage, output_storage, storage_map, post_thunk_clear, computed, compute_map, updated_vars)
   1045 
   1046             if platform.python_implementation() == "CPython":
-> 1047                 assert c0 == sys.getrefcount(node_n_inputs)
   1048         else:
   1049             lazy = self.lazy

AssertionError: 

For the code:

prob = np.zeros((I, max_T, K), dtype=object) * (-1) 
alpha =np.zeros((I, max_T, K), dtype=object) * (-1)
yy = np.ones((I, max_T, K), dtype=object)
PREDICTED_Y = np.zeros((I, max_T, K), dtype=object)
observed_data = {}

for i in range(I):
    observed_data[i] = {}
    for skill_num in range(K):
        observed_data[i][skill_num] = {}
        for t in range(T[i]):
            observed_data[i][skill_num][t] = []

for user_num in range(I):
    
    for t in range(T[user_num]):
        user_obsY = obsY[user_num][t].flatten()
        user_idxY = idxY[user_num][t].flatten()
        
        for l in range(len(user_obsY)):
            obs = int(user_obsY[l])
            skill_num = int(user_idxY[l] - 1)
            
            if skill_num >= K:
                continue
            
            observed_data[user_num][skill_num][t].append(obs)
        
    t = T[user_num]
    user_obsY = obsY[user_num][:t].flatten()
    user_idxY = idxY[user_num][:t].flatten()
    timestep = -1
    for l in range(len(user_obsY)):
        if l%4 == 0:
            timestep += 1
        skill_num = int(user_idxY[l] - 1)
        if skill_num == 22:
            continue
        obs = int(user_obsY[l])

trace = None
summary = None
sample_num = 2500 
chains = 4
tune = 500 
with pm.Model() as bkt:
  #priors 
  #Tk
  learn   = pm.Beta('learn', alpha=1, beta=1, shape=(K, 1))
  
  #Guess 
  guess   = pm.Uniform('guess',0,0.4,shape=(K,1))

  #Slip
  slip = pm.Uniform('slip',0,0.4,shape=(K,1))

  #Initial Probability of a student knowing a skill
  know0 = pm.Uniform('initialprob',0,1,shape=(K,1))

  for student in range(I):
    for skill in range(MAXSKILLS):
      #equation 1A
      idx = int(idxY[student][0][skill] - 1)
      if idx>=K:
          continue
      prob[student][0][idx]=know0[idx,0]

    for step in range(1,T[student]):
      for skill in range(MAXSKILLS):
        idx = int(idxY[student][step][skill] - 1)
        
        if idx>=K:
          continue
        if obsY[student][step-1][skill]==1:
          alpha[student][step][idx]=  prob[student][step-1][idx]*(1-slip[idx,0])/(prob[student][step-1][idx]*(1-slip[idx,0]) + (1-prob[student][step-1][idx])*guess[idx,0])
        if obsY[student][step-1][skill]==0:
          alpha[student][step][idx]=  prob[student][step-1][idx]*(slip[idx,0])/(prob[student][step-1][idx]*(slip[idx,0]) + (1-prob[student][step-1][idx])*(1-guess[idx,0]))

    for step in range(1,T[student]):
      for skill in range(MAXSKILLS):
        idx = int(idxY[student][step][skill] - 1)
        
        if idx>=K:
          continue
        prob[student][step][idx]=alpha[student][step][idx] + (1-alpha[student][step][idx])*learn[idx][0]


    for step in range(1,T[student]):
      for skill in range(MAXSKILLS):
        idx = int(idxY[student][step][skill] - 1)
        
        if idx>=K:
          continue
        yy[student][step][idx]=prob[student][step-1][idx]*(1 - slip[idx, 0]) + (1-prob[student][step-1][idx])*guess[idx, 0]

    for t in tqdm(range(T[student])):
      for skill in range(MAXSKILLS):
        idx = int(idxY[student][step][skill] - 1)
        
        if idx>=K:
          continue
        obsData = pm.Minibatch(observed_data[student][idx][t], batch_size=batch_size)
        y_name = "y_" + str(student) + "_" + str(t) + "_" + str(idx) 
        PREDICTED_Y[student][t][idx]  =pm.Bernoulli(y_name, p=yy[student][t][idx], observed=obsData)
  # sampling_end = time.time()
  trace = pm.sample(sample_num, tune=tune, chains=chains)

Can someone please let me know why this is happening and how one should go about debugging this?