code: def _cp_n_param(tensor_shape, rank, weights=False):
      """Number of parameters of a CP decomposition for a given `rank` and full `tensor_shape`.
  
      Parameters
      ----------
      tensor_shape : int tuple
          shape of the full tensor to decompose (or approximate)
  
      rank : tuple
          rank of the CP decomposition
  
      Returns
      -------
      n_params : int
          Number of parameters of a CP decomposition of rank `rank` of a full tensor of shape `tensor_shape`
      """
      factors_params = rank * np.sum(tensor_shape)
      if weights:
          return factors_params + rank
      else:
          return factors_params
  
imports: from .None import backend
  from .base import fold, tensor_to_vec
  from ._factorized_tensor import FactorizedTensor
  from .tenalg import khatri_rao, unfolding_dot_khatri_rao
  from .metrics.factors import congruence_coefficient
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: _cp_n_param(tensor_shape, rank, weights) and returns: unknown, factors_params