Your won’t work, since the second argument is expected to be a generator as given in the docs.
If you remove it,
for i in sampler:
    print(i)

will return a random sequence of the passed indices.



 hitbuyi:

where is the meaning of ramdom of this function


The passed indices will be randomly sampled.



 hitbuyi:

and where is the meaning of “subset” this function itself?


You are able to pass the indices of a subset to the sampler instead of a data source.