def build_attention(name,
                    head_num,
                    activation,
                    history_only,
                    trainable=True):
    """Get multi-head self-attention builder.

    :param name: Prefix of names for internal layers.
    :param head_num: Number of heads in multi-head self-attention.
    :param activation: Activation for multi-head self-attention.
    :param history_only: Only use history data.
    :param trainable: Whether the layer is trainable.
    :return:
    """

    def _build_attention(x):
        return MultiHeadAttention(head_num=head_num,
                                  activation=activation,
                                  history_only=history_only,
                                  trainable=trainable,
                                  name=name,)(x)

    return _build_attention
Get multi-head self-attention builder.

    :param name: Prefix of names for internal layers.
    :param head_num: Number of heads in multi-head self-attention.
    :param activation: Activation for multi-head self-attention.
    :param history_only: Only use history data.
    :param trainable: Whether the layer is trainable.
    :return:
    
keras_textclassification/keras_layers/transformer.py