code: def make_svd_non_negative(tensor, U, S, V, nntype=True):
      """Use NNDSVD method to transform SVD results into a non-negative form. This
      method leads to more efficient solving with NNMF [1].
  
      Parameters
      ----------
      tensor : tensor being decomposed
      U, S, V: SVD factorization results
      nntype : {'nndsvd', 'nndsvda'}
          Whether to fill small values with 0.0 (nndsvd), or the tensor mean (nndsvda, default).
  
      [1]: Boutsidis & Gallopoulos. Pattern Recognition, 41(4): 1350-1362, 2008.
      """
      if nntype is True:
          nntype = "nndsvda"
  
      # NNDSVD initialization
      W = tl.zeros_like(U)
      H = tl.zeros_like(V)
  
      # The leading singular triplet is non-negative
      # so it can be used as is for initialization.
      W = tl.index_update(
          W, tl.index[:, 0], tl.sqrt(S[0]) * tl.abs(U[:, 0])
      )
      H = tl.index_update(
          H, tl.index[0, :], tl.sqrt(S[0]) * tl.abs(V[0, :])
      )
  
      for j in range(1, min(tl.shape(U)[1], tl.shape(V)[0])):
          x, y = U[:, j], V[j, :]
  
          # extract positive and negative parts of column vectors
          x_p, y_p = tl.clip(x, a_min=0.0), tl.clip(y, a_min=0.0)
          x_n, y_n = tl.abs(tl.clip(x, a_max=0.0)), tl.abs(
              tl.clip(y, a_max=0.0)
          )
  
          # and their norms
          x_p_nrm, y_p_nrm = tl.norm(x_p), tl.norm(y_p)
          x_n_nrm, y_n_nrm = tl.norm(x_n), tl.norm(y_n)
  
          m_p, m_n = x_p_nrm * y_p_nrm, x_n_nrm * y_n_nrm
  
          # choose update
          if m_p > m_n:
              u = x_p / x_p_nrm
              v = y_p / y_p_nrm
              sigma = m_p
          else:
              u = x_n / x_n_nrm
              v = y_n / y_n_nrm
              sigma = m_n
  
          lbd = tl.sqrt(S[j] * sigma)
          W = tl.index_update(W, tl.index[:, j], lbd * u)
          H = tl.index_update(H, tl.index[j, :], lbd * v)
  
      # After this point we no longer need H
      eps = tl.eps(tensor.dtype)
  
      if nntype == "nndsvd":
          W = soft_thresholding(W, eps)
          H = soft_thresholding(H, eps)
      elif nntype == "nndsvda":
          avg = tl.mean(tensor)
          W = tl.where(
              W < eps, tl.ones(tl.shape(W), **tl.context(W)) * avg, W
          )
          H = tl.where(
              H < eps, tl.ones(tl.shape(H), **tl.context(H)) * avg, H
          )
      else:
          raise ValueError(
              f'Invalid nntype parameter: got {nntype} instead of one of ("nndsvd", "nndsvda")'
          )
  
      return W, H
  
file_path: tensorly/tensorly/tenalg/svd.py
imports: import warnings
  import tensorly
  from .proximal import soft_thresholding
label_desc: Use image node_id 2 for calling a global function with example usage: make_svd_non_negative(tensor, U, S, V, nntype) and returns: W,  H