It seems that the error came from another completely different part of the code. As the model was being tried in a Jupyter notebook, there was a previous cell to configure the pytensor flags to watch more clearly the errors in the model. So there was a cell with this configuration:
pytensor.config.optimizer='None'
That configuration made every model to raise the same error.
I’ll close the post as solved but if it helps to anyone
:DD