code: def hard_thresholding(tensor, number_of_non_zero):
      """
      Proximal operator of the l0 ``norm''
      Keeps greater "number_of_non_zero" elements untouched and sets other elements to zero.
  
      Parameters
      ----------
      tensor : ndarray
      number_of_non_zero : int
  
      Returns
      -------
      ndarray
            Thresholded tensor on which the operator has been applied
      """
      tensor_vec = tl.copy(tl.tensor_to_vec(tensor))
      sorted_indices = tl.argsort(
          tl.flip(tl.argsort(tl.abs(tensor_vec), axis=0), axis=0),
          axis=0,
      )
      return tl.reshape(
          tl.where(
              sorted_indices < number_of_non_zero,
              tensor_vec,
              tl.tensor(0, **tl.context(tensor_vec)),
          ),
          tensor.shape,
      )
  
file_path: tensorly/tensorly/tenalg/proximal.py
imports: import tensorly
  import numpy
label_desc: Use image node_id 11 for calling a global function with example usage: hard_thresholding(tensor, number_of_non_zero) and returns: tl