code: def testvalidate_cp_rank():
      """Test validate_cp_rank with random sizes"""
      tensor_shape = tuple(np.random.randint(1, 100, size=4))
      n_param_tensor = np.prod(tensor_shape)
  
      # Rounding = floor
      rank = validate_cp_rank(
          tensor_shape, rank="same", rounding="floor"
      )
      n_param = _cp_n_param(tensor_shape, rank)
      assert_(n_param <= n_param_tensor)
  
      # Rounding = ceil
      rank = validate_cp_rank(
          tensor_shape, rank="same", rounding="ceil"
      )
      n_param = _cp_n_param(tensor_shape, rank)
      assert_(n_param >= n_param_tensor)
  
imports: import numpy
  import tensorly
  from ..tenalg import khatri_rao, mode_dot
  from ..cp_tensor import cp_to_tensor, cp_to_unfolded, cp_to_vec, _validate_cp_tensor, cp_normalize, CPTensor, cp_mode_dot, cp_norm, cp_flip_sign, _cp_n_param, validate_cp_rank, cp_lstsq_grad, cp_permute_factors
  from ..base import unfold, tensor_to_vec
  from tensorly.random import random_cp
  from tensorly.testing import assert_equal, assert_raises, assert_, assert_array_equal, assert_array_almost_equal
  import pytest
label_desc: Use image node_id 10 for calling a global function with example usage: testvalidate_cp_rank() without return types