code: def test_cp_to_tensor(
      shapeU1, shapeU2, shapeU3, shapeU4, true_res, columns, rows
  ):
      U1 = ivy.reshape(ivy.arange(1, 10, dtype=float), shapeU1)
      U2 = ivy.reshape(ivy.arange(10, 22, dtype=float), shapeU2)
      U3 = ivy.reshape(ivy.arange(22, 28, dtype=float), shapeU3)
      U4 = ivy.reshape(ivy.arange(28, 34, dtype=float), shapeU4)
      U = [ivy.array(t) for t in [U1, U2, U3, U4]]
      true_res = ivy.array(true_res)
      res = ivy.CPTensor.cp_to_tensor((ivy.ones(shape=(3,)), U))
      assert np.allclose(res, true_res)
  
      matrices = [
          ivy.arange(k * columns, dtype=float).reshape((k, columns))
          for k in rows
      ]
      tensor = ivy.CPTensor.cp_to_tensor(
          (ivy.ones(shape=(columns,)), matrices)
      )
      for i in range(len(rows)):
          unfolded = ivy.unfold(tensor, mode=i)
          U_i = matrices.pop(i)
          reconstructed = ivy.matmul(
              U_i, ivy.permute_dims(ivy.khatri_rao(matrices), (1, 0))
          )
          assert np.allclose(reconstructed, unfolded)
          matrices.insert(i, U_i)
  
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 6 for calling a global function with example usage: test_cp_to_tensor(shapeU1, shapeU2, shapeU3, shapeU4, true_res, columns, rows) without return types