Contrastive Classification and Representation Learning with Probabilistic Interpretation