code: def test_validate_cp_tensor(true_shape, true_rank):
      cp_tensor = ivy.random_cp(true_shape, true_rank)
      (weights, factors) = ivy.CPTensor.cp_normalize(cp_tensor)
  
      # Check correct rank and shapes are returned
      shape, rank = ivy.CPTensor.validate_cp_tensor((weights, factors))
      np.testing.assert_equal(
          true_shape,
          shape,
          err_msg=f"Returned incorrect shape (got {shape}, expected {true_shape})",
      )
      np.testing.assert_equal(
          rank,
          true_rank,
          err_msg=f"Returned incorrect rank (got {rank}, expected {true_rank})",
      )
  
      # One of the factors has the wrong rank
      factors[0], copy = ivy.random_uniform(shape=(4, 4)), factors[0]
      with np.testing.assert_raises(ValueError):
          ivy.CPTensor.validate_cp_tensor((weights, factors))
  
      # Not the correct amount of weights
      factors[0] = copy
      wrong_weights = weights[1:]
      with np.testing.assert_raises(ValueError):
          ivy.CPTensor.validate_cp_tensor((wrong_weights, factors))
  
      # Not enough factors
      with np.testing.assert_raises(ValueError):
          ivy.CPTensor.validate_cp_tensor((weights[:1], factors[:1]))
  
file_path: ivy/ivy_tests/test_ivy/test_misc/test_factorized_tensor/test_cp_tensor.py
imports: import ivy
  import numpy
  import pytest
label_desc: Use image node_id 12 for calling a global function with example usage: test_validate_cp_tensor(true_shape, true_rank) without return types