The easiest way would be to introduce a new variable to the dataset (sample_counter) and increment it in every call of __getitem__. If you additionally pass the batchsize as argument to the __init__ you can do something like:
if not (self.sample_counter%self.batchsize):
    reload_headers()