How to generate labels for self-supervised training?

I've been reading a lot lately about self-supervised learning and I didn't understand very well how to generate the desired label for a given image.

Let's say that I have an image classification task, and I have very little labeled data.

How can I generate the target label from the other data in the dataset?

If $$D = \{ A, B \}$$ is a dataset that contains both labelled and unlabelled data, where $$A = \{ (x_i, y_i) \}_{i=1}^n$$, $$B = \{ x_i \}_{i=1}^m$$, and $$m \gg n$$, then, to use self-supervised learning (for representation learning), you could follow these steps
1. learn representations of your images $$x_i$$ by training a neural network $$M$$ with $$B$$ to solve a so-called pretext (or auxiliary task); there are many pre-text tasks: you can find many examples here; this step is the self-supervised learning part;
2. use transfer learning to fine-tune $$M$$ with $$A$$, in a supervised way