I prefer to get an idea what to expect from the example I’ve included above.
With
torch.manual_seed(42)

data_size = 1500
num_classes = 3

batch_size = 40

I’m getting:
inputs torch.Size([1500]) tensor([   0,    1,    2,  ..., 1497, 1498, 1499])
targets torch.Size([1500]) tensor([2, 2, 1,  ..., 1, 2, 2], dtype=torch.int32)
class_sample_count (3,) [529 493 478]
weights (3,) [0.00189036 0.0020284  0.00209205]
...
class_sample_count_new [541 463 496]