code: def wait_for_any_cluster(contexts):
      
      try:
          earliest_retry_at = min(ctx.retry_at for ctx in contexts.values()
                                  if not ctx.failed)
      except ValueError:  # can't take min() of empty sequence
          raise AllClustersFailedException(
              "Could not find appropriate cluster for worker build."
          )
  
      time_until_next = earliest_retry_at - dt.datetime.now()
      time.sleep(max(timedelta(seconds=0), time_until_next).seconds)
docs: Wait until any of the clusters are out of retry-wait
  
      :param contexts: List[ClusterRetryContext]
      :raises: AllClustersFailedException if no more retry attempts allowed