batch_size is not a keyword argument in your __init__ function, it is just the second one
Either call it as (data_source, 3) or in the init function use (self, data_source, batch_size=1, replacement=False).
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.
Thanks for your response. I have changed the initialization code to:
sample = CustomSampler(data_source, 3)
but error was the same
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in ()
----> 1 sample = CustomSampler(data_source, 3)
TypeError: CustomSampler() takes 1 positional argument but 2 were given