Whenever you're ready, walk me through how you'd approach this.
Explain attention, and describe the space complexity of various parts of the Transformer.
Cover scaled dot-product self-attention, multi-head attention, positional information, feed-forward layers, and the distinction between parameter memory, activation memory, and temporary workspace. Express complexity using sequence length n, model width d, feed-forward width d_ff, number of heads h, and batch size b. Discuss both training and autoregressive inference, including the KV cache. A concise derivation and pseudocode or Python implementation are expected.