code: def simplex_prox(tensor, parameter):
      """
      Projects the input tensor on the simplex of radius parameter.
  
      Parameters
      ----------
      tensor : ndarray
      parameter : float
  
      Returns
      -------
      ndarray
  
      References
      ----------
      .. [1]: Held, Michael, Philip Wolfe, and Harlan P. Crowder.
              "Validation of subgradient optimization."
              Mathematical programming 6.1 (1974): 62-88.
      """
      # Making it work for 1-dimensional tensors as well
      if tl.ndim(tensor) > 1:
          row, col = tl.shape(tensor)
      else:
          row = tl.shape(tensor)[0]
          col = 1
          tensor = tl.reshape(tensor, [row, col])
      tensor_sort = tl.flip(tl.sort(tensor, axis=0), axis=0)
      # Broadcasting is used to divide rows by 1,2,3...
      cumsum_min_param_by_k = (
          tl.cumsum(tensor_sort, axis=0) - parameter
      ) / tl.cumsum(tl.ones([row, 1]), axis=0)
      # Added -1 to correspond to a Python index
      to_change = (
          tl.sum(
              tl.where(tensor_sort > cumsum_min_param_by_k, 1, 0),
              axis=0,
          )
          - 1
      )
      difference = tl.zeros(col)
      for i in range(col):
          difference = tl.index_update(
              difference,
              tl.index[i],
              cumsum_min_param_by_k[to_change[i], i],
          )
      if col > 1:
          return tl.clip(tensor - difference, a_min=0)
      else:
          return tl.tensor_to_vec(tl.clip(tensor - difference, a_min=0))
  
file_path: tensorly/tensorly/tenalg/proximal.py
imports: import tensorly
  import numpy
label_desc: Use image node_id 10 for calling a global function with example usage: simplex_prox(tensor, parameter) and returns: tl, tl