code: def proj_l1(x, radius=1, out=None):
      r
  
      if out is None:
          out = x.space.element()
  
      u = x.ufuncs.absolute()
      v = x.ufuncs.sign()
      proj_simplex(u, radius, out)
      out *= v
  
      return out
docs: r"""Projection onto l1-ball.
  
      Projection onto::
  
          ``{ x \in X | ||x||_1 \leq r}``
  
      with ``r`` being the radius.
  
      Parameters
      ----------
      space : `LinearSpace`
          Space / domain ``X``.
      radius : positive float, optional
          Radius ``r`` of the ball.
  
      Returns
      -------
      prox_factory : callable
          Factory for the proximal operator to be initialized.
  
      Notes
      -----
      The projection onto an l1-ball can be computed by projection onto a
      simplex, see [D+2008] for details.
  
      References
      ----------
      [D+2008] Duchi, J., Shalev-Shwartz, S., Singer, Y., and Chandra, T.
      *Efficient Projections onto the L1-ball for Learning in High dimensions*.
      ICML 2008, pp. 272-279. http://doi.org/10.1145/1390156.1390191
  
      See Also
      --------
      proximal_linfty : proximal for l-infinity norm
      proj_simplex : projection onto simplex