Multivariate Output External Function Class

From the Examples Gallery, Using a “black box” likelihood function (numpy) — PyMC example gallery

I have attempted to modify the code to output a vector of values.

# define a pytensor Op for our likelihood function
class LogLike(pt.Op):

    Specify what type of object will be passed and returned to the Op when it is
    called. In our case we will be passing it a vector of values (the parameters
    that define our model) and returning a single "scalar" value (the

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

    def __init__(self, loglike, data, x, sigma):
        Initialise the Op with various things that our log-likelihood function
        requires. Below are the things that are needed in this particular

            The log-likelihood (or whatever) function we've defined
            The "observed" data that our log-likelihood function takes in
            The dependent variable (aka 'x') that our model requires
            The noise standard deviation that our function requires.

        # add inputs as class attributes
        self.likelihood = loglike = data
        self.x = x
        self.sigma = sigma

    def perform(self, node, inputs, outputs):
        # the method that is used when calling the Op
        (theta,) = inputs  # this will contain my variables

        # call the log-likelihood function
        logl = self.likelihood(theta, self.x,, self.sigma)

        outputs[0][0] = np.array(logl)  # output the log-likelihood

My question is how do I modify this to output a vector. I made the change of

otypes = [pt.dvector]  # outputs a single scalar value (the log likelihood)

but I was wondering on how to change for the size of vector I am interested in.

outputs[0][0] = np.array(logl)  # output the log-likelihood