code: def delay(self, n, start_time):
      
      if (n > self.max_retries or
          (n > self.min_retries and
           time.time() - start_time > self.max_retry_period)):
        return -1
      return min(
          math.pow(self.backoff_factor, n-1) * self.initial_delay,
          self.max_delay)
docs: Calculate delay before the next retry.
  
      Args:
        n: the number of current attempt. The first attempt should be 1.
        start_time: the time when retry started in unix time.
  
      Returns:
        Number of seconds to wait before next retry. -1 if retry should give up.