Create a weighted random sampler.
y_data – The output class labels.
class2idx – A dictionary to convert class strings to integer.