code: def proximal_operator(
      tensor,
      non_negative=None,
      l1_reg=None,
      l2_reg=None,
      l2_square_reg=None,
      unimodality=None,
      normalize=None,
      simplex=None,
      normalized_sparsity=None,
      soft_sparsity=None,
      smoothness=None,
      monotonicity=None,
      hard_sparsity=None,
      n_const=1,
      order=0,
  ):
      """
      Proximal operator solves a convex optimization problem. Let f be a
      convex proper lower-semicontinuous function, the proximal operator of f is :math:`\\argmin_x(f(x) + 1/2||x - v||_2^2)`.
      This operator can be used to solve constrained optimization problems as a generalization to projections on convex sets.
      Therefore, proximal gradients are used for constrained tensor decomposition problems in the literature.
  
      Parameters
      ----------
      tensor : ndarray
      non_negative : bool or dictionary
          This constraint is clipping negative values to '0'.
          If it is True, non-negative constraint is applied to all modes.
      l1_reg : float or list or dictionary, optional
          Penalizes the factor with the given regularizer
      l2_reg : float or list or dictionary, optional
          Penalizes the factor with the given regularizer
      l2_square_reg : float or list or dictionary, optional
          Penalizes the factor with the given regularizer
      unimodality : bool or dictionary, optional
          If it is True, unimodality constraint is applied to all modes.
          Applied to each column seperately.
      normalize : bool or dictionary, optional
          This constraint divides all the values by maximum value of the input array.
          If it is True, normalize constraint is applied to all modes.
      simplex : float or list or dictionary, optional
          Projects on the simplex with the given parameter
          Applied to each column seperately.
      normalized_sparsity : float or list or dictionary, optional
          Normalizes with the norm after hard thresholding
      soft_sparsity : float or list or dictionary, optional
          Simplex operator using soft thresholding
      smoothness : float or list or dictionary, optional
          Optimizes the factors by solving a banded system
      monotonicity : bool or dictionary, optional
          Projects columns to monotonically decreasing distrbution
          Applied to each column seperately.
          If it is True, monotonicity constraint is applied to all modes.
      hard_sparsity : float or list or dictionary, optional
          Hard thresholding with the given threshold
      n_const : int
          Number of constraints. If it is None, function returns input tensor.
          Default : 1
      order : int
          Specifies which constraint to implement if several constraints are selected as input
          Default : 0
      Returns
      -------
      tensor : updated tensor according to the selected constraint, which is the solution of the optimization problem above.
               If constraint is None, function returns the same tensor.
  
      References
      ----------
      .. [1]: Moreau, J. J. (1962). Fonctions convexes duales et points proximaux dans un espace hilbertien.
              Comptes rendus hebdomadaires des séances de l'Académie des sciences, 255, 2897-2899.
      .. [2]: Parikh, N., & Boyd, S. (2014). Proximal algorithms.
              Foundations and Trends in optimization, 1(3), 127-239.
      """
      if n_const is None:
          return tensor
      constraint, parameter = validate_constraints(
          non_negative=non_negative,
          l1_reg=l1_reg,
          l2_reg=l2_reg,
          l2_square_reg=l2_square_reg,
          unimodality=unimodality,
          normalize=normalize,
          simplex=simplex,
          normalized_sparsity=normalized_sparsity,
          soft_sparsity=soft_sparsity,
          smoothness=smoothness,
          monotonicity=monotonicity,
          hard_sparsity=hard_sparsity,
          n_const=n_const,
          order=order,
      )
      if constraint is None:
          return tensor
      elif constraint == "non_negative":
          return tl.clip(tensor, 0, tl.max(tensor))
      elif constraint == "l1_reg":
          return soft_thresholding(tensor, parameter)
      elif constraint == "l2_reg":
          return l2_prox(tensor, parameter)
      elif constraint == "l2_square_reg":
          return l2_square_prox(tensor, parameter)
      elif constraint == "unimodality":
          return unimodality_prox(tensor)
      elif constraint == "normalize":
          return tensor / tl.max(tl.abs(tensor))
      elif constraint == "simplex":
          return simplex_prox(tensor, parameter)
      elif constraint == "normalized_sparsity":
          return normalized_sparsity_prox(tensor, parameter)
      elif constraint == "soft_sparsity":
          return soft_sparsity_prox(tensor, parameter)
      elif constraint == "smoothness":
          return smoothness_prox(tensor, parameter)
      elif constraint == "monotonicity":
          return monotonicity_prox(tensor)
      elif constraint == "hard_sparsity":
          return hard_thresholding(tensor, parameter)
  
file_path: tensorly/tensorly/tenalg/proximal.py
imports: import tensorly
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: proximal_operator(tensor, non_negative, l1_reg, l2_reg, l2_square_reg, unimodality, normalize, simplex, normalized_sparsity, soft_sparsity, smoothness, monotonicity, hard_sparsity, n_const, order) and returns: tensor, tensor, tl, soft_thresholding, l2_prox, l2_square_prox, unimodality_prox, unknown, simplex_prox, normalized_sparsity_prox, soft_sparsity_prox, smoothness_prox, monotonicity_prox, hard_thresholding