Mechanics of Self-Attention