def estimate_u_multiple_tries(sumLogPi=None, nDoc=0, gamma=1.0, alpha0=1.0,
                              initu=None, initU=None, approx_grad=False,
                              fList=[1e7, 1e8, 1e10], **kwargs):
  ''' Estimate 2K-vector "u" via gradient descent,
        gracefully using multiple restarts with progressively weaker tolerances
        until one succeeds

      Returns
      --------
      u : 2K-vector of positive parameters
      fofu : scalar value of minimization objective
      Info : dict

      Raises
      --------
      ValueError with FAILURE in message if all restarts fail
  '''
  K = sumLogPi.size - 1
  if initU is not None:
    initu = initU
  if initu is not None and not np.allclose(initu[-K:], alpha0):
    uList = [initu, None]
  else:
    uList = [None] 

  nOverflow = 0
  u = None
  Info = dict()
  msg = ''
  for trial, myTuple in enumerate(itertools.product(uList, fList)):
    initu, factr = myTuple
    try:
      u, fofu, Info = estimate_u(sumLogPi, nDoc, gamma, alpha0,
                                initu=initu, factr=factr, approx_grad=approx_grad)
      Info['nRestarts'] = trial
      Info['factr'] = factr
      Info['msg'] = Info['task']
      del Info['grad']
      del Info['task']
      break
    except __HOLE__ as err:
      if str(err).count('FAILURE') == 0:
        raise err
      msg = str(err)
      if str(err).count('overflow') > 0:
        nOverflow += 1

  if u is None:
    raise ValueError("FAILURE! " + msg)
  Info['nOverflow'] = nOverflow
  return u, fofu, Info
dataset/ETHPy150Open daeilkim/refinery/refinery/bnpy/bnpy-dev/bnpy/allocmodel/admix/OptimizerForHDPFullVarModel.py/estimate_u_multiple_tries