Solved by ptrblck in post #2 
              
              
                WeightedRandomSampler expects a weight tensor assigning the weight values to each sample, not the class index. 
Have a look at this post which gives you an example.