@charan_Vjy
Thanks for your help. I didn’t understand what exactly I need to do.
Should the number of data in the “WeightedRandomSampler” be the total number of data or batch_size or the length of the smallest class?
And also, Are my target values wrong in this way?
I made a change like below and got the error when I want to make the targets. If you could show me by code, that would be great.

sampler = WeightedRandomSampler([224,477,5027,4497,483,247], len(samples_weight), replacement=False)

RuntimeError: cannot sample n_sample > prob_dist.size(-1) samples without replacement