Connecting PyMC3 to external code - help with understanding Theano custom Ops

I finally got it to work with:

def grad(self, inputs, grad_outputs):
    (theta,) = inputs
    J = self.model_grad(theta)
    return [tt.dot(grad_outputs, J)[0]]

Maybe I don’t fully understand how this method works. The code above returns a tensor with a single element, but I thought it should’ve returned a vector.