code: def _proj_l1_scalar_root(v, gamma):
      r
  
      if norm_l1(v) <= gamma:
          return v
      else:
          av = np.abs(v)
          fn = lambda t: np.sum(np.maximum(0, av - t)) - gamma
          t = optim.brentq(fn, 0, av.max())
          return prox_l1(v, t)
docs: r"""Projection operator of the :math:`\ell_1` norm. The solution is
      computed via the method of Sec. 6.5.2 in :cite:`parikh-2014-proximal`.
  
      There is no `axis` parameter since the algorithm for computing the
      solution treats the input `v` as a single vector.
  
  
      Parameters
      ----------
      v : array_like
        Input array :math:`\mathbf{v}`
      gamma : float
        Parameter :math:`\gamma`
  
      Returns
      -------
      x : ndarray
        Output array