code: def _check_cpd_inputs(X, rank):
      
      if X.ndim < 3:
          raise ValueError("Array with X.ndim > 2 expected.")
      if rank <= 0 or not isinstance(rank, int):
          raise ValueError("Rank is invalid.")
docs: Checks that inputs to optimization function are appropriate.
  
      Parameters
      ----------
      X : ndarray
          Tensor used for fitting CP decomposition.
      rank : int
          Rank of low rank decomposition.
  
      Raises
      ------
      ValueError: If inputs are not suited for CP decomposition.