code: def calculate_sleep_time(attempt, delay_factor=5.0, randomization_factor=.5, max_delay=120):
      
      if attempt <= 0:
          return 0
  
      # We subtract one to get exponents: 1, 2, 3, 4, 5, ..
      delay = float(2 ** (attempt - 1)) * float(delay_factor)
      # Apply randomization factor.  Only increase the delay here.
      delay = delay * (randomization_factor * random.random() + 1)
      # Always limit with a maximum delay
      return min(delay, max_delay)
docs: Calculate the sleep time between retries, in seconds.
  
      Based off of `taskcluster.utils.calculateSleepTime`, but with kwargs instead
      of constant `delay_factor`/`randomization_factor`/`max_delay`.  The taskcluster
      function generally slept for less than a second, which didn't always get
      past server issues.
  
      Args:
          attempt (int): the retry attempt number
          delay_factor (float, optional): a multiplier for the delay time.  Defaults to 5.
          randomization_factor (float, optional): a randomization multiplier for the
              delay time.  Defaults to .5.
          max_delay (float, optional): the max delay to sleep.  Defaults to 120 (seconds).
  
      Returns:
          float: the time to sleep, in seconds.