Train with pseudo label

Hi, I want to train a classifier with pseudo label.
In this process.

1. [Source data] -> [train a classifier ]
2. [Target data] -> [Generate a pseudo label with above the classifier]
3. [Target data] -> [train the classifier with a pseudo label]

In this case, I’m not sure this codes are make sense.
target_pseudo_loss = criterion(target_pseudo_label, target_pseudo_label)
this line makes me confusing because the predicted label always equals answer label…
Does it make sense? if not how can I modify this code?

# 1. [Source data] -> [train a classifier ]
...
source_out = classifier(source_img)
source_loss= criterion(source_out, source_label)
optimizer.zero_grad()
source_loss.backward()
optimizer.step()

# 2. [Target data] -> [Generate a pseudo label with above the classifier]
target_pseudo_label = classifier(target_img.detach())

# 3. [Target data] -> [train the classifier with a pseudo label]

target_pseudo_loss = criterion(target_pseudo_label, target_pseudo_label)
optimizer.zero_grad()
target_pseudo_loss.backward()
optimizer.step()