alx:

Also found this comment “It looks like weights is a list of weights per data point in the data set we are drawing from, NOT a weight per class”


Yes, WeightedRandomSampler expects a weight value for each sample in the dataset.
Here 52 is a complete example.
Alternatively, you could also use a class weight and pass it to your criterion, if it fits your use case.
E.g. nn.CrossEntropyLoss 27 accepts a weight tensor, which assigns a specific weight to each class.