How to use Ensemble Learning for balancing data

HI. i have a imbalanced dataset with number of sample in class1:98,class2:68,class3:21 .
now i want to run my classification code A thousand times and every time i want to randomly choose 21 samples for each class.
i think i should use Ensemble Learning but i don’t know how? and which technique of Ensemble Learning is suitable for my problem?
if you have PyTorch code for my problem i will be very thankful if you share it with me.

I’m not sure I understand the use case completely but assuming you want to use a model ensemble with each trained model, this would mean your final model would run the forward pass 1000 times (using the corresponding models) to classify a single input batch. Is this indeed what you are planning to do?