Yes my answer is not really clear sorry 
When you do this call sample = CustomSampler(data_source, batch_size = 3)
It will give data_source as first argument to the constructor and 3 to the named argument batch_size.
If you look at how you declared your constructor def __init__(self, data_source, batch_size, replacement=False): it has self as argument as always, then a first argument that will be stored in the variable named data_source, a second argument that will be stored in a variable named batch_size and a named argument replacement that will be stored in a variable with the same name and that has default value False.
You try to supply the second argument as a named argument while it is a positional argument in your function definition.