Having trouble reproduction code

I’m trying reproduction the code in: GVFP_2021/figure_4_data_4pMC.ipynb at main · pachterlab/GVFP_2021 · GitHub
which use pymc3 to implement sampling for author’s custom distribution. I want to implement a custom sampling similar to the probability form in it, so I reproduce this code.
After installing pymc3 and theano according to the corresponding versions, I encountered an error when trying to import them, and it seems like a problem that cannot be easily solved. I want to modify the code that uses pymc3 and theano to use pymc and pytensor instead, but I am unable to solve this issue. Therefore, I am seeking for help.

Blockquote

class LogLike(tt.Op):

itypes = [tt.dvector] # expects a vector of parameter values when called
otypes = [tt.dscalar] # outputs a single scalar value (the log likelihood)

def __init__(self, mx, data, likelihood):
    
    # add inputs as class attributes
    self.mx = mx
    self.data = data
    self.likelihood = likelihood
    
def perform(self, node, inputs, outputs):
    
    phi, = inputs # this contains parmeters
    logl = self.likelihood(phi, self.mx, self.data) # calls the log-likelihood function
    outputs[0][0] = np.array(logl) # output the log-likelihood

This function gets parameter posteriors via smc.

def get_parameter_posteriors_smc(string_ID, mx, data, ll_func, draws_=1000, chains_=2, cores_=2):
“”““Arguments changed for sample_smc function. Here is pymc3 3.8"””
# Parameter bounds
epsilon = 0.005
x_min, x_max = epsilon, 1-epsilon
y_min, y_max = epsilon, 1-epsilon

# Define log likelihood
logl_op = LogLike(mx, data, ll_func)
def logl_fun(phi):
    return logl_op(phi)

# Define PyMC3 model
model = pm.Model()
with model:
    # Priors
    x_ = pm.Uniform('x', lower=x_min, upper=x_max)
    y_ = pm.Uniform('y', lower=y_min, upper=y_max)
    z_ = pm.Uniform('z', lower=x_min, upper=x_max)
    q_ = pm.Uniform('q', lower=y_min, upper=y_max)

    phi = tt.as_tensor_variable([x_, y_, z_, q_])

    # Likelihood
    pm.Potential('likelihood', logl_fun(phi))
    
    
# Run PyMC3 model
#start_time = ti.time()
with model:
    trace = pm.sample_smc(draws = draws_, chains = chains_, cores = cores_)
#print("--- %s seconds ---" % (ti.time() - start_time))
    
# Plot and save trace
#with model:
#    axes = az.plot_trace(trace)
#    fig = axes.ravel()[0].figure
#    #fig.savefig("smc_results/trace_"+string_ID+".png", bbox_inches='tight')
#    fig.savefig("trace_"+string_ID+".pdf", bbox_inches='tight')
    
return trace

Blockquote