To learn what photos show without any labels, a model gets two crops of each photo and has to tell which crops belong together. For one crop, the model scores how alike it is to every crop in the batch (“Invent the score”, from −1 to 1). twin is the index of the other crop of the same photo; the rest are strangers. Write twin_loss(similarities, twin, temperature): one number training pushes down, lower when the crop picks out its twin better. temperature sets how sharply it picks (“Confident or cautious”).