Robust and data-efficient generalization of self-supervised machine learning for diagnostic imaging