Transformers are almost optimal metalearners for linear classification