Define a custom loss. I had an example where I wanted to treat different samples in batch differently. I’m assuming you want them to go through the same forward prop i.e. forward() function in the model file.
Write your data loader such that you know the positions of the labelled samples and unlabelled samples. This won’t be hard. Then at the time of your loss calculation, simply re-write a custom version of CrossEntropyLoss based on Pytorch docs and for the unlabelled samples you can neglect them by not adding them to the equation.
Writing custom loss functions is not that hard so don’t worry