code: def _make_ufunc(func, index=Ellipsis, **kwargs):  # noqa: D202
      
  
      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
docs: Make ufunc from function.