@staticmethod
def _every(times, step_size, index):
    """
        Given a loop over batches of an iterable and an operation that should
        be performed every few elements. Determine whether the operation should
        be called for the current index.
        """
    current = index * step_size
    step = current // times * times
    reached = current >= step
    overshot = current >= step + step_size
    return current and reached and not overshot
