code: def test_tucker_to_vec():
      """Test for tucker_to_vec
  
      Notes
      -----
      Assumes that tucker_to_tensor works correctly
      """
      G = tl.tensor(np.random.random((4, 3, 5, 2)))
      ranks = [2, 2, 3, 4]
      U = [
          tl.tensor(np.random.random((ranks[i], G.shape[i])))
          for i in range(tl.ndim(G))
      ]
      vec = tensor_to_vec(tucker_to_tensor((G, U)))
      assert_array_almost_equal(tucker_to_vec((G, U)), vec)
      assert_array_almost_equal(
          tucker_to_vec((G, U)),
          tl.dot(kronecker(U), tensor_to_vec(G)),
          decimal=5,
      )
  
file_path: tensorly/tensorly/tests/test_tucker_tensor.py
imports: import numpy
  from ..None import backend
  from ..base import unfold, tensor_to_vec
  from ..tucker_tensor import tucker_to_tensor, tucker_to_unfolded, tucker_to_vec, _validate_tucker_tensor, tucker_mode_dot, tucker_normalize, _tucker_n_param, validate_tucker_rank
  from ..tenalg import kronecker, mode_dot
  from ..testing import assert_array_equal, assert_array_almost_equal, assert_equal, assert_raises, assert_
  from ..random import random_tucker
label_desc: Use image node_id 4 for calling a global function with example usage: test_tucker_to_vec() without return types