Implement the scaled dot-product attention mechanism, a core building block of the Transformer architecture.