def count_samples(self, name, window_size=20):
        """
        Return the number of samples logged in the past `window_size` iterations.
        """
        samples = 0
        data = self._history[name].values()
        for _, iter_ in reversed(data):
            if iter_ > data[-1][1] - window_size:
                samples += 1
            else:
                break
        return samples

        Return the number of samples logged in the past `window_size` iterations.
        
ControlNet-v1-1-nightly/annotator/oneformer/detectron2/utils/events.py