Implement the self-attention mechanism, a fundamental component of transformer models used in NLP and computer vision.
Your task is to implement the self_attention function that computes attention output given Query (Q), Key (K), and Value (V) matrices.
The self-attention formula is: Attention(Q, K, V) = softmax(Q * K^T / sqrt(d_k)) * V
where d_k is the dimensionality of the key vectors (number of columns in K).
Input:
Output:
Steps:
Note: The helper function compute_qkv is provided to compute Q, K, V from input X and weight matrices.