<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _check_cpd_inputs(X, rank):
 """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. """

    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.")