def _make_ufunc(func, index=Ellipsis, **kwargs):  # noqa: D202
    """Make ufunc from function."""

    def _ufunc(ary):
        target = np.empty(ary.shape[:-2])
        for idx in np.ndindex(target.shape):
            target[idx] = np.asarray(func(ary[idx].ravel(), **kwargs))[index]
        return target

    return _ufunc
Make ufunc from function.