code: func (g *Cloud) waitForTPUOp(ctx context.Context, op *tpuapi.Operation) (*tpuapi.Operation, error) {
  	if err := wait.PollInfinite(30*time.Second, func() (bool, error) {
  		// Check if context has been cancelled.
  		select {
  		case <-ctx.Done():
  			klog.V(3).Infof("Context for operation %q has been cancelled: %s", op.Name, ctx.Err())
  			return true, ctx.Err()
  		default:
  		}
  
  		klog.V(3).Infof("Waiting for operation %q to complete...", op.Name)
  
  		start := time.Now()
  		g.operationPollRateLimiter.Accept()
  		duration := time.Since(start)
  		if duration > 5*time.Second {
  			klog.V(2).Infof("Getting operation %q throttled for %v", op.Name, duration)
  		}
  
  		var err error
  		op, err = g.tpuService.projects.Locations.Operations.Get(op.Name).Do()
  		if err != nil {
  			return true, err
  		}
  		if op.Done {
  			klog.V(3).Infof("Operation %q has completed", op.Name)
  			return true, nil
  		}
  		return false, nil
  	}); err != nil {
  		return nil, fmt.Errorf("failed to wait for operation %q: %s", op.Name, err)
  	}
  	return op, nil
  }
docs: // waitForTPUOp checks whether the op is done every 30 seconds before the ctx
  // is cancelled.