Explain the difference between supervised and self-supervised learning, and write a simple helper function to generate contrastive loss.