code: def log_progress(
      iterable,
      logger,
      batch_size=10000,
      progress_message="Processing... ({})",
      done_message="Done! (Total: {})",
  ):
      
      i = 0
      for x in iterable:
          yield x
          i += 1
          if not i % batch_size:
              logger.info(progress_message.format(i))
      logger.info(done_message.format(i))
docs: Log progress while iterating.