code: def iq_handler(type_, payload_cls, *, with_send_reply=False):
      
  
      if (not hasattr(payload_cls, "TAG") or
              (aioxmpp.IQ.CHILD_MAP.get(payload_cls.TAG) is not
               aioxmpp.IQ.payload.xq_descriptor) or
              payload_cls not in aioxmpp.IQ.payload._classes):
          raise ValueError(
              "{!r} is not a valid IQ payload "
              "(use IQ.as_payload_class decorator)".format(
                  payload_cls,
              )
          )
  
      def decorator(f):
          add_handler_spec(
              f,
              HandlerSpec(
                  (_apply_iq_handler, (type_, payload_cls)),
                  require_deps=(),
              ),
              kwargs=dict(with_send_reply=with_send_reply),
          )
          return f
      return decorator
docs: Register the decorated function or coroutine function as IQ request
      handler.
  
      :param type_: IQ type to listen for
      :type type_: :class:`~.IQType`
      :param payload_cls: Payload XSO class to listen for
      :type payload_cls: :class:`~.XSO` subclass
      :param with_send_reply: Whether to pass a function to send a reply
         to the decorated callable as second argument.
      :type with_send_reply: :class:`bool`
  
      :raises ValueError: if `payload_cls` is not a registered IQ payload
  
      If the decorated function is not a coroutine function, it must return an
      awaitable instead.
  
      .. seealso::
  
          :meth:`~.StanzaStream.register_iq_request_handler` for more
              details on the `type_`, `payload_cls` and
              `with_send_reply` arguments, as well as behaviour expected
              from the decorated function.
  
          :meth:`aioxmpp.IQ.as_payload_class`
              for a way to register a XSO as IQ payload
  
      .. versionadded:: 0.11
  
         The `with_send_reply` argument.
  
      .. versionchanged:: 0.10
  
          The decorator now checks if `payload_cls` is a valid, registered IQ
          payload and raises :class:`ValueError` if not.