I’m not completely sure, but based on the code snippet it seems samples should contain indices, as it’s passed into an nn.Embedding layer in the model.
If that’s the case, samples should be of dtype=torch.long.
Again, if that’s the case, samples should not be able to require gradients.
At least I’m not aware of a method to get valid gradients for integer values.
But I must say, I’m also not really an expert in NLP tasks, so maybe you can correct me and we can figure out, what’s going on.