Build a batched version of self-attention