No, your usage is wrong and won’t chose 5 out of 100 indices.
As described in the docs 1:

Samples elements randomly from a given list of indices, without replacement.

which means you are supposed to pass the indices the sampler should randomly sample from as the first argument.
E.g. if your original index is defined as idx = torch.arange(100), you could select the desired 5 indices and pass it to the sampler: SubsetRandomSampler(idx[:5]).
If you want to randomly pick these 5 indices, you could use:
idx_subset = idx[torch.randperm(len(idx))[:5]]