Implement batched multi-head encoder-decoder attention multi_head_cross_attention(decoder_x, encoder_out, W_q, W_k, W_v, W_o, num_heads, src_pad_mask=None).
Inputs:
decoder_x (B, T, d_model) supplies the queries; encoder_out (B, S, d_model) supplies keys and values (S and T may differ).W_q, W_k, W_v, W_o are (d_model, d_model); d_model is divisible by num_heads and .src_pad_mask (optional) is (B, S), boolean or 0/1, with True/1 at padded source positions; every row has at least one real token.Computation:
(B, H, T, S).V, concatenate the heads in order to (B, T, d_model), then apply .Return (output, weights) with shapes (B, T, d_model) and (B, H, T, S).