docstr: Generate all slices along the first mode from a PARAFAC2 tensor.
  
  Generates a list of all slices from a PARAFAC2 tensor. A list is returned
  since the tensor might have varying size along the second mode. To return
  a tensor, see the ``parafac2_to_tensor`` function instead.shape
  
  The decomposition is on the form :math:`(A [B_i] C)` such that
  the i-th frontal slice, :math:`X_i`, of :math:`X` is given by
  
  .. math::
  
      X_i = B_i diag(a_i) C^T,
  
  where :math:`diag(a_i)` is the diagonal matrix whose nonzero entries are
  equal to the :math:`i`-th row of the :math:`I times R` factor matrix
  :math:`A`, :math:`B_i` is a :math:`J_i times R` factor matrix such
  that the cross product matrix :math:`B_{i_1}^T B_{i_1}` is constant
  for all :math:`i`, and :math:`C` is a :math:`K times R` factor matrix.To
  compute this decomposition, we reformulate the expression for :math:`B_i`
  such that
  
  .. math::
  
      B_i = P_i B,
  
  where :math:`P_i` is a :math:`J_i times R` orthogonal matrix and :math:`B`
  is a :math:`R times R` matrix.
  
  An alternative formulation of the PARAFAC2 decomposition is that the
  tensor element :math:`X_{ijk}` is given by
  
  .. math::
  
      X_{ijk} = sum_{r=1}^R A_{ir} B_{ijr} C_{kr},
  
  with the same constraints hold for :math:`B_i` as above.
  
  Parameters
  ----------
  parafac2_tensor : Parafac2Tensor - (weight, factors, projection_matrices)
      * weights : 1D array of shape (rank, )
          weights of the factors
      * factors : List of factors of the PARAFAC2 decomposition
          Contains the matrices :math:`A`, :math:`B` and :math:`C` described above
      * projection_matrices : List of projection matrices used to create evolving
          factors.
  
  Returns
  -------
      A list of full tensors of shapes [P[i].shape[1], C.shape[1]], where
      P is the projection matrices and C is the last factor matrix of the
      Parafac2Tensor.
docstr_tok: ["Generate","all","slices","along","the","first","mode","from","a","PARAFAC2","tensor",".","Generates","a","list","of","all","slices","from","a","PARAFAC2","tensor",".","A","list","is","returned","since","the","tensor","might","have","varying","size","along","the","second","mode",".","To","return","a","tensor",",","see","the","``","parafac2_to_tensor","``","function","instead.shape","The","decomposition","is","on","the","form",":","math",":","`","(","A","[","B_i","]","C",")","`","such","that","the","i-th","frontal","slice",",",":","math",":","`","X_i","`",",","of",":","math",":","`","X","`","is","given","by","..","math",":",":","X_i","=","B_i","diag","(","a_i",")","C^T",",","where",":","math",":","`","diag","(","a_i",")","`","is","the","diagonal","matrix","whose","nonzero","entries","are","equal","to","the",":","math",":","`","i","`","-th","row","of","the",":","math",":","`","I","times","R","`","factor","matrix",":","math",":","`","A","`",",",":","math",":","`","B_i","`","is","a",":","math",":","`","J_i","times","R","`","factor","matrix","such","that","the","cross","product","matrix",":","math",":","`","B_","{","i_1","}","^T","B_","{","i_1","}","`","is","constant","for","all",":","math",":","`","i","`",",","and",":","math",":","`","C","`","is","a",":","math",":","`","K","times","R","`","factor","matrix.To","compute","this","decomposition",",","we","reformulate","the","expression","for",":","math",":","`","B_i","`","such","that","..","math",":",":","B_i","=","P_i","B",",","where",":","math",":","`","P_i","`","is","a",":","math",":","`","J_i","times","R","`","orthogonal","matrix","and",":","math",":","`","B","`","is","a",":","math",":","`","R","times","R","`","matrix",".","An","alternative","formulation","of","the","PARAFAC2","decomposition","is","that","the","tensor","element",":","math",":","`","X_","{","ijk","}","`","is","given","by","..","math",":",":","X_","{","ijk","}","=","sum_","{","r=1","}","^R","A_","{","ir","}","B_","{","ijr","}","C_","{","kr","}",",","with","the","same","constraints","hold","for",":","math",":","`","B_i","`","as","above",".","Parameters","--","--","--","--","--","parafac2_tensor",":","Parafac2Tensor","-","(","weight",",","factors",",","projection_matrices",")","*","weights",":","1D","array","of","shape","(","rank",",",")","weights","of","the","factors","*","factors",":","List","of","factors","of","the","PARAFAC2","decomposition","Contains","the","matrices",":","math",":","`","A","`",",",":","math",":","`","B","`","and",":","math",":","`","C","`","described","above","*","projection_matrices",":","List","of","projection","matrices","used","to","create","evolving","factors",".","Returns","--","--","--","-","A","list","of","full","tensors","of","shapes","[","P","[","i","]",".shape","[","1","]",",","C.shape","[","1","]","]",",","where","P","is","the","projection","matrices","and","C","is","the","last","factor","matrix","of","the","Parafac2Tensor","."]
code: def parafac2_to_slices(parafac2_tensor, validate=True):
      """Generate all slices along the first mode from a PARAFAC2 tensor.
  
      Generates a list of all slices from a PARAFAC2 tensor. A list is returned
      since the tensor might have varying size along the second mode. To return
      a tensor, see the ``parafac2_to_tensor`` function instead.shape
  
      The decomposition is on the form :math:`(A [B_i] C)` such that
      the i-th frontal slice, :math:`X_i`, of :math:`X` is given by
  
      .. math::
  
          X_i = B_i diag(a_i) C^T,
  
      where :math:`diag(a_i)` is the diagonal matrix whose nonzero entries are
      equal to the :math:`i`-th row of the :math:`I times R` factor matrix
      :math:`A`, :math:`B_i` is a :math:`J_i times R` factor matrix such
      that the cross product matrix :math:`B_{i_1}^T B_{i_1}` is constant
      for all :math:`i`, and :math:`C` is a :math:`K times R` factor matrix.To
      compute this decomposition, we reformulate the expression for :math:`B_i`
      such that
  
      .. math::
  
          B_i = P_i B,
  
      where :math:`P_i` is a :math:`J_i times R` orthogonal matrix and :math:`B`
      is a :math:`R times R` matrix.
  
      An alternative formulation of the PARAFAC2 decomposition is that the
      tensor element :math:`X_{ijk}` is given by
  
      .. math::
  
          X_{ijk} = sum_{r=1}^R A_{ir} B_{ijr} C_{kr},
  
      with the same constraints hold for :math:`B_i` as above.
  
      Parameters
      ----------
      parafac2_tensor : Parafac2Tensor - (weight, factors, projection_matrices)
          * weights : 1D array of shape (rank, )
              weights of the factors
          * factors : List of factors of the PARAFAC2 decomposition
              Contains the matrices :math:`A`, :math:`B` and :math:`C` described above
          * projection_matrices : List of projection matrices used to create evolving
              factors.
  
      Returns
      -------
          A list of full tensors of shapes [P[i].shape[1], C.shape[1]], where
          P is the projection matrices and C is the last factor matrix of the
          Parafac2Tensor.
      """
      if validate:
          ivy.Parafac2Tensor.validate_parafac2_tensor(parafac2_tensor)
      weights, (A, B, C), projections = parafac2_tensor
      if weights is not None:
          A = A * weights
          weights = None
  
      decomposition = weights, (A, B, C), projections
      I, _ = A.shape  # noqa: E741
      return [
          ivy.Parafac2Tensor.parafac2_to_slice(
              decomposition, i, validate=False
          )
          for i in range(I)
      ]
  
imports: from .base import FactorizedTensor
  import ivy
  from copy import deepcopy
label_desc: Use image node_id 16 for calling the Parafac2Tensor obj's underlying member method code with example usage: obj.parafac2_to_slices(parafac2_tensor, validate) and returns: unknown