Untangling tradeoffs between recurrence and self-attention in artificial neural networks