It looks like train_sampleweights is a numpy array.
Could you convert it to a torch.tensor using train_sampleweights = torch.from_numpy(train_sampleweights) before passing it to the WeightedRandomSampler?