Instead of using torch.cat you could append the results to a list and convert it to a tensor afterwards.


You could use torch.randperm and slice the first k indices. This would make sure that all indices are unique but shuffled.