[Edit] Trouble with "aesara.tensor.as_tensor_variable" when building custom fitting function

I’m dusting off some old code to do Bayesian MCMC fits to some experimental data. After upgrading pymc3 and aesara (version info below) my model no longer builds. The line below defining fit throws a “Not Implemented” error in aesara.tensor.as_tensor_variable. The code worked as shown for pymc3 version 3.8 and whichever version of theano was contemporary to that.

Update: the trouble seems to come from aesara v.2.0.1 and up. I suspect this change (from the release notes):

aesara.tensor.as_tensor_function is now a functools.singledispatch function

I’m not familiar with singledispatch and what it does. How can I make my code compatible?

with pm.Model() as model61:
    
    x = pm.Data('x',xdata) # xdata is ndarray with shape=samples, dtype=np.float32
    y = pm.Data('y',ydata) # ydata is ndarray with shape=(samples,Ncolor), dtype=np.float32
    
    b = pm.HalfNormal('b', 0.2,shape=Ncolor)
    sigma = pm.HalfNormal('sigma',0.03,shape=Ncolor) 
    
    fit = tt.outer(x,b) # not my real function. Only the broken part.
    
    yobs = pm.Normal('yobs',fit,sigma,observed=y)

The resulting errors are

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-46-5345c0bfe47f> in <module>
     11     amp = pm.Deterministic('amp',a-c)
     12 
---> 13     fit = tt.outer(x,b) # not my real function. Only the broken part.
     14 
     15     yobs = pm.Normal('yobs',fit,sigma,observed=y)

~/.conda/envs/colorfits-mkl/lib/python3.9/site-packages/aesara/tensor/math.py in outer(x, y)
   2282     if y.ndim != 1:
   2283         y = y.flatten()
-> 2284     return dot(x.dimshuffle(0, "x"), y.dimshuffle("x", 0))
   2285 
   2286 

~/.conda/envs/colorfits-mkl/lib/python3.9/site-packages/aesara/tensor/math.py in dot(l, r)
   1982 
   1983     if not isinstance(l, Variable):
-> 1984         l = as_tensor_variable(l)
   1985 
   1986     if not isinstance(r, Variable):

~/.conda/envs/colorfits-mkl/lib/python3.9/site-packages/aesara/tensor/__init__.py in as_tensor_variable(x, name, ndim, **kwargs)
     36 
     37     """
---> 38     return _as_tensor_variable(x, name, ndim, **kwargs)
     39 
     40 

~/.conda/envs/colorfits-mkl/lib/python3.9/functools.py in wrapper(*args, **kw)
    875                             '1 positional argument')
    876 
--> 877         return dispatch(args[0].__class__)(*args, **kw)
    878 
    879     funcname = getattr(func, '__name__', 'singledispatch function')

~/.conda/envs/colorfits-mkl/lib/python3.9/site-packages/aesara/tensor/__init__.py in _as_tensor_variable(x, name, ndim, **kwargs)
     43     x, name: Optional[str], ndim: Optional[int], **kwargs
     44 ) -> NoReturn:
---> 45     raise NotImplementedError("")
     46 
     47 

NotImplementedError: 
%watermark -iv -v

Python implementation: CPython
Python version       : 3.9.2
IPython version      : 7.22.0

pandas    : 1.2.3
pymc3     : 3.11.2
aesara    : 2.0.4
numpy     : 1.20.2

[Edit: additional info]
[Edit: found the breaking change in aesara, trimmed code to minimum NWE]