Click4Ai

229.

Hard

Implement a multi-head attention mechanism. **Example:** For input [[1,2],[3,4]] and [[5,6],[7,8]], the output should be a weighted sum of the input values. **Constraints:** Use NumPy for efficient computation.

Test Cases

Test Case 1
Input: [[1,2],[3,4]] [[5,6],[7,8]] [[9,10],[11,12]]
Expected: [[2.5,3.5],[6.5,7.5]]
Test Case 2
Input: [[1,1],[1,1]] [[1,1],[1,1]] [[1,1],[1,1]]
Expected: [[1.0,1.0],[1.0,1.0]]
+ 3 hidden test cases