async def METHOD_NAME(
    self,
    session: ProfileSession,
    message_json: Union[str, bytes],
    recipient_keys: Sequence[str],
    routing_keys: Sequence[str],
    sender_key: str,
) -> Union[str, bytes]:
    """Encode an outgoing message for transport.
    Args:
        session: The profile session for providing wallet access
        message_json: The message body to serialize
        recipient_keys: A sequence of recipient verkeys
        routing_keys: A sequence of routing verkeys
        sender_key: The verification key of the sending agent
    Returns:
        The encoded message
    Raises:
        MessageEncodeError: If the message could not be encoded
    """
    if sender_key and recipient_keys:
        pack = self.pack(
            session, message_json, recipient_keys, routing_keys, sender_key
        )
        message = await (self.task_queue and self.task_queue.run(pack) or pack)
    else:
        message = message_json
    return message