Change kernel size for stencil computation dynamically

Hi everyone!
I was wondering if there’s a simple way of adjusting the kernel size of a stencil dynamically. At the moment I’m defining a 3x3 kernel manually inside my function, but I’d like to use 5x5, 7x7, … kernel sizes as well and preferably by just passing a parameter to my function.
At the moment it looks like this:

@stencil(cval=-1)
def stencil_function(x):
    arr_in = np.array([x[-1, -1], x[-1, 0], x[-1, 1],
                       x[ 0, -1], x[ 0, 0], x[ 0, 1],
                       x[ 1, -1], x[ 1, 0], x[ 1, 1]])
   ## do calculations using this kernel
   ## ...

@guvectorize(
    ["int16[:, :], int16[:, :]"],
    "(n, m) -> (n, m)", nopython=True, target='parallel'
)
def apply_stencil(arr, out):
    out[:] = stencil_function(arr)