docstr: Validate a cp_tensor in the form (weights, factors)
  
      Return the rank and shape of the validated tensor
  
  Parameters
  ----------
  cp_tensor
      CPTensor or (weights, factors)
  
  Returns
  -------
  (shape, rank)
      size of the full tensor and rank of the CP tensor
docstr_tok: ["Validate","a","cp_tensor","in","the","form","(","weights",",","factors",")","Return","the","rank","and","shape","of","the","validated","tensor","Parameters","--","--","--","--","--","cp_tensor","CPTensor","or","(","weights",",","factors",")","Returns","--","--","--","-","(","shape",",","rank",")","size","of","the","full","tensor","and","rank","of","the","CP","tensor"]
code: def validate_cp_tensor(cp_tensor):
      """Validate a cp_tensor in the form (weights, factors)
  
          Return the rank and shape of the validated tensor
  
      Parameters
      ----------
      cp_tensor
          CPTensor or (weights, factors)
  
      Returns
      -------
      (shape, rank)
          size of the full tensor and rank of the CP tensor
      """
      if isinstance(cp_tensor, CPTensor):
          # it's already been validated at creation
          return cp_tensor.shape, cp_tensor.rank
      elif isinstance(cp_tensor, (float, int)):  # 0-order tensor
          return 0, 0
  
      weights, factors = cp_tensor
  
      ndim = len(factors[0].shape)
      if ndim == 2:
          rank = int(ivy.shape(factors[0])[1])
      elif ndim == 1:
          rank = 1
      else:
          raise ValueError(
              "Got a factor with 3 dimensions but CP factors should be at most 2D, of"
              " shape (size, rank)."
          )
  
      shape = []
      for i, factor in enumerate(factors):
          s = ivy.shape(factor)
          if len(s) == 2:
              current_mode_size, current_rank = s
          else:  # The shape is just (size, ) if rank 1
              current_mode_size, current_rank = *s, 1
  
          if current_rank != rank:
              raise ValueError(
                  "All the factors of a CP tensor should have the same number of"
                  f" column.However, factors[0].shape[1]={rank} but"
                  f" factors[{i}].shape[1]={ivy.shape(factor)[1]}."
              )
          shape.append(current_mode_size)
  
      if weights is not None and len(weights) != rank:
          raise ValueError(
              f"Given factors for a rank-{rank} CP tensor but"
              f" len(weights)={ivy.shape(weights)}."
          )
  
      return tuple(shape), rank
  
imports: from .base import FactorizedTensor
  import ivy
label_desc: Use image node_id 15 for calling the CPTensor obj's underlying member method code with example usage: obj.validate_cp_tensor(cp_tensor) and returns: tuple,  rank, cp_tensor,  cp_tensor, int,  int