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
      Whether or not Parafac2Tensors can be used as input.
  
  Returns
  -------
      Parafac2Tensor with factor matrices and weights 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","Whether","or","not","Parafac2Tensors","can","be","used","as","input",".","Returns","--","--","--","-","Parafac2Tensor","with","factor","matrices","and","weights","extracted","from","a","CPTensor"]
code: def from_CPTensor(cls, 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
          Whether or not Parafac2Tensors can be used as input.
  
      Returns
      -------
          Parafac2Tensor with factor matrices and weights 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 = ivy.qr(B)
      projections = [Q for _ in range(ivy.shape(A)[0])]
      B = R
      return Parafac2Tensor((weights, (A, B, C), projections))
  
imports: from .base import FactorizedTensor
  import ivy
  from copy import deepcopy
label_desc: Use image node_id 11 for calling the Parafac2Tensor obj's underlying member method code with example usage: obj.from_CPTensor(cls, cp_tensor, parafac2_tensor_ok) and returns: Parafac2Tensor, Parafac2Tensor