How to handle imbalance dataset on text classification

If each sample contains a single target value, you should be able to directly use the WeightedRandomSampler as described in this example.