class_docstr: A wrapper class for the PARAFAC2 decomposition.
docstr: Create a Parafac2Tensor from a CPTensor
  
  Parameters:
  -----------
  cp_tensor: CPTensor or Parafac2Tensor
      If it is a Parafac2Tensor, then the argument ``parafac2_tensor_ok`` must be True'
  parafac2_tensor: bool (optional)
      Whether or not Parafac2Tensors can be used as input.
  
  Returns:
  --------
  Parafac2Tensor
      Parafac2Tensor with factor matrices and weigths extracted from a CPTensor
docstr_tok: ["Create","a","Parafac2Tensor","from","a","CPTensor","Parameters",":","--","--","--","--","--","-","cp_tensor",":","CPTensor","or","Parafac2Tensor","If","it","is","a","Parafac2Tensor",",","then","the","argument","``","parafac2_tensor_ok","``","must","be","True'","parafac2_tensor",":","bool","(","optional",")","Whether","or","not","Parafac2Tensors","can","be","used","as","input",".","Returns",":","--","--","--","--","Parafac2Tensor","Parafac2Tensor","with","factor","matrices","and","weigths","extracted","from","a","CPTensor"]
code: def from_CPTensor(self, cp_tensor, parafac2_tensor_ok=False):
      """Create a Parafac2Tensor from a CPTensor
  
      Parameters:
      -----------
      cp_tensor: CPTensor or Parafac2Tensor
          If it is a Parafac2Tensor, then the argument ``parafac2_tensor_ok`` must be True'
      parafac2_tensor: bool (optional)
          Whether or not Parafac2Tensors can be used as input.
  
      Returns:
      --------
      Parafac2Tensor
          Parafac2Tensor with factor matrices and weigths extracted from a CPTensor
      """
      if parafac2_tensor_ok and len(cp_tensor) == 3:
          return Parafac2Tensor(cp_tensor)
      elif len(cp_tensor) == 3:
          raise TypeError(
              "Input is not a CPTensor. If it is a Parafac2Tensor, then the argument ``parafac2_tensor_ok`` must be True"
          )
  
      weights, (A, B, C) = cp_tensor
      Q, R = T.qr(B)
      projections = [Q for _ in range(T.shape(A)[0])]
      B = R
      return Parafac2Tensor((weights, (A, B, C), projections))
  
imports: from .None import backend
  from .base import unfold, tensor_to_vec
  from ._factorized_tensor import FactorizedTensor
label_desc: Use image node_id 2 for calling the Parafac2Tensor obj's underlying member method code with example usage: obj.from_CPTensor(cp_tensor, parafac2_tensor_ok) and returns: Parafac2Tensor, Parafac2Tensor