code: def numpy_invalid_op_as_exception(func):
      
      def func_wrapper(*args, **kwargs):
          np.seterr(invalid='raise')
          result = func(*args, **kwargs)
          np.seterr(invalid='warn')
          return result
      return func_wrapper
docs: A decorator that allows catching numpy invalid operations
      as exceptions (the default behaviour is raising warnings).