docstr: Return parafac2_tensor with factors normalised to unit length.
  
  Turns ``factors = [|U_1, ... U_n|]`` into ``[weights; |V_1, ... V_n|]``,
  where the columns of each `V_k` are normalized to unit Euclidean length
  from the columns of `U_k` with the normalizing constants absorbed into
  `weights`. In the special case of a symmetric tensor, `weights` holds the
  eigenvalues of the tensor.
  
  Parameters
  ----------
  parafac2_tensor
      Parafac2Tensor = (weight, factors, projections)
      factors is list of matrices, all with the same number of columns
      i.e.::
          for u in U:
              u[i].shape == (s_i, R)
  
      where `R` is fixed while `s_i` can vary with `i`
  
  Returns
  -------
  Parafac2Tensor
    normalisation_weights, normalised_factors, normalised_projections
docstr_tok: ["Return","parafac2_tensor","with","factors","normalised","to","unit","length",".","Turns","``","factors","=","[","|U_1",",","...","U_n|","]","``","into","``","[","weights",";","|V_1",",","...","V_n|","]","``",",","where","the","columns","of","each","`","V_k","`","are","normalized","to","unit","Euclidean","length","from","the","columns","of","`","U_k","`","with","the","normalizing","constants","absorbed","into","`","weights","`",".","In","the","special","case","of","a","symmetric","tensor",",","`","weights","`","holds","the","eigenvalues","of","the","tensor",".","Parameters","--","--","--","--","--","parafac2_tensor","Parafac2Tensor","=","(","weight",",","factors",",","projections",")","factors","is","list","of","matrices",",","all","with","the","same","number","of","columns","i.e",".",":",":","for","u","in","U",":","u","[","i","]",".shape","==","(","s_i",",","R",")","where","`","R","`","is","fixed","while","`","s_i","`","can","vary","with","`","i","`","Returns","--","--","--","-","Parafac2Tensor","normalisation_weights",",","normalised_factors",",","normalised_projections"]
code: def parafac2_normalise(parafac2_tensor):
      """Return parafac2_tensor with factors normalised to unit length.
  
      Turns ``factors = [|U_1, ... U_n|]`` into ``[weights; |V_1, ... V_n|]``,
      where the columns of each `V_k` are normalized to unit Euclidean length
      from the columns of `U_k` with the normalizing constants absorbed into
      `weights`. In the special case of a symmetric tensor, `weights` holds the
      eigenvalues of the tensor.
  
      Parameters
      ----------
      parafac2_tensor
          Parafac2Tensor = (weight, factors, projections)
          factors is list of matrices, all with the same number of columns
          i.e.::
              for u in U:
                  u[i].shape == (s_i, R)
  
          where `R` is fixed while `s_i` can vary with `i`
  
      Returns
      -------
      Parafac2Tensor
        normalisation_weights, normalised_factors, normalised_projections
      """
      # allocate variables for weights, and normalized factors
      _, rank = ivy.Parafac2Tensor.validate_parafac2_tensor(
          parafac2_tensor
      )
      weights, factors, projections = parafac2_tensor
  
      # if (not copy) and (weights is None):
      #     warnings.warn('Provided copy=False and weights=None: a new Parafac2Tensor'
      #                   'with new weights and factors normalised inplace will
      # be returned.')
      #     weights = T.ones(rank, **T.context(factors[0]))
  
      # The if test below was added to enable inplace edits
      # however, TensorFlow does not support inplace edits
      # so this is always set to True
      if True:
          factors = [deepcopy(f) for f in factors]
          projections = [deepcopy(p) for p in projections]
          if weights is not None:
              factors[0] = factors[0] * weights
          weights = ivy.ones(rank, dtype=factors[0].dtype)
  
      for i, factor in enumerate(factors):
          scales = ivy.sqrt(ivy.sum(ivy.square(factor), axis=0))
          weights = weights * scales
          scales_non_zero = ivy.where(
              scales == 0,
              ivy.ones(ivy.shape(scales), dtype=factors[0].dtype),
              scales,
          )
          factors[i] = factor / scales_non_zero
  
      return Parafac2Tensor((weights, factors, projections))
  
imports: from .base import FactorizedTensor
  import ivy
  from copy import deepcopy
label_desc: Use image node_id 13 for calling the Parafac2Tensor obj's underlying member method code with example usage: obj.parafac2_normalise(parafac2_tensor) and returns: Parafac2Tensor