This use case seems to be a bit more complicated, since you have multiple class indices for each sentence.
Even if we sample each sentence, we would need to calculate the weight for it.
Since the sentence lengths are most likely different, we can’t just multiply the word weights, as this would penalize long sentences.
Assuming we have a few sentences and a dictionary of two words with weights 0.1 and 0.01.
Ideally we would like to create batches with the same number of word counts.
If the sentences look like this:
s0 = [w0, w1]                 -> [0.1, 0.01]
s1 = [w0, w1, w1, w1, w1, w1] -> [0.1, 0.01, 0.01, 0.01, 0.01, 0.01]
s2 = [w1]                     -> [0.01]

, we would need to somehow calculate the valid weight for each sentence.
I haven’t tried it yet, but do you think it would work, if you multiply the word weights and normalize if with the Nth root, where N is the sentence length?
This would yield sentence weights of:
s0 => 0.0316
s1 => 0.0147
s2 => 0.01

Let me know, if I’m missing something.