On the Theory of Transfer Learning: The Importance of Task Diversity