Implement multi-head self-attention from scratch using numpy's einsum for the QKV projections, attention score computation, and context aggregation. Given an input tensor X of shape (batch, seq_len, d_in), learned weight matrices W_q, W_k, W_v of shape (d_in, d_out), an output projection W_o of shape (d_out, d_out), and the number of heads, compute the multi-head attention output. The function must support an optional causal mask that prevents each position from attending to future positions. Use einsum-style contractions to express each tensor operation: (1) project X to Q, K, V using a single contraction per matrix, (2) reshape into heads, (3) compute per-head attention scores scaled by 1/sqrt(d_head), (4) apply causal masking when requested, (5) apply softmax along the key axis, (6) aggregate values, and (7) apply the output projection. Return a nested Python list (use .tolist()). The constraint d_out must be divisible by num_heads.