code: func slowStartBatch(count int, initialBatchSize int, fn func() error) (int, error) {
  	remaining := count
  	successes := 0
  	for batchSize := integer.IntMin(remaining, initialBatchSize); batchSize > 0; batchSize = integer.IntMin(2*batchSize, remaining) {
  		errCh := make(chan error, batchSize)
  		var wg sync.WaitGroup
  		wg.Add(batchSize)
  		for i := 0; i < batchSize; i++ {
  			go func() {
  				defer wg.Done()
  				if err := fn(); err != nil {
  					errCh <- err
  				}
  			}()
  		}
  		wg.Wait()
  		curSuccesses := batchSize - len(errCh)
  		successes += curSuccesses
  		if len(errCh) > 0 {
  			return successes, <-errCh
  		}
  		remaining -= batchSize
  	}
  	return successes, nil
  }
docs: // slowStartBatch tries to call the provided function a total of 'count' times,
  // starting slow to check for errors, then speeding up if calls succeed.
  //
  // It groups the calls into batches, starting with a group of initialBatchSize.
  // Within each batch, it may call the function multiple times concurrently.
  //
  // If a whole batch succeeds, the next batch may get exponentially larger.
  // If there are any failures in a batch, all remaining batches are skipped
  // after waiting for the current batch to complete.
  //
  // It returns the number of successful calls to the function.