def estimate_u(sumLogPi=None, nDoc=0, gamma=1.0, alpha0=1.0, initu=None, approx_grad=False, factr=1.0e7, **kwargs):
  ''' Run gradient optimization to estimate best v for specified problem

      Returns
      -------- 
      vhat : K-vector of values, 0 < v < 1
      fofvhat: objective function value at vhat
      Info : dict with info about estimation algorithm

      Raises
      --------
      ValueError on an overflow, any detection of NaN, or failure to converge
  '''
  sumLogPi = np.squeeze(np.asarray(sumLogPi, dtype=np.float64))
  assert sumLogPi.ndim == 1
  K = sumLogPi.size - 1
  if initu is None:
    initu = np.hstack( [np.ones(K), alpha0*np.ones(K)])
  assert initu.size == 2*K

  initc = np.log(initu)
  myFunc = lambda c: objFunc_c(c, sumLogPi, nDoc, gamma, alpha0)
  myGrad = lambda c: objGrad_c(c, sumLogPi, nDoc, gamma, alpha0)
  
  with warnings.catch_warnings():
    warnings.filterwarnings('error', category=RuntimeWarning,
                               message='overflow')
    try:
      chat, fhat, Info = scipy.optimize.fmin_l_bfgs_b(myFunc, initc,
                                                  fprime=myGrad, disp=None,
                                                  approx_grad=approx_grad,
                                                  factr=factr,
                                                  **kwargs)
    except RuntimeWarning:
      raise ValueError("FAILURE: overflow!" )
    except __HOLE__:
      raise ValueError("FAILURE: NaN found!")
      
  if Info['warnflag'] > 1:
    raise ValueError("FAILURE: " + Info['task'])

  uhat = np.exp(chat)
  Info['initu'] = initu
  Info['objFunc'] = lambda u: objFunc_u(u, sumLogPi, nDoc, gamma, alpha0)
  Info['gradFunc'] = lambda u: objGrad_u(u, sumLogPi, nDoc, gamma, alpha0)
  return uhat, fhat, Info

########################################################### Objective/gradient
########################################################### in terms of u
dataset/ETHPy150Open daeilkim/refinery/refinery/bnpy/bnpy-dev/bnpy/allocmodel/admix/OptimizerForHDPFullVarModel.py/estimate_u