The weights should be assigned to each sample, not only the inverse class count as described in the previous post.
Usually the num_samples are then set to the length of the Dataset, i.e. the number of samples.