Domain Generalization for Text Classification with Memory-Based Supervised Contrastive Learning