code: def test_partial_tensor_to_vec():
      """Test for partial_tensor_to_vec"""
      X = np.arange(24).reshape((3, 4, 2))
      n_samples = 3
  
      ###################################
      # Samples are the first dimension #
      ###################################
      tensor = T.tensor(
          np.concatenate([X[None, ...] + i for i in range(n_samples)])
      )
      # we created here a tensor with 3 samples, each sample being similar to X
      vectorised = partial_tensor_to_vec(tensor, skip_begin=1)
      vec_X = tensor_to_vec(T.tensor(X))
      for j in range(n_samples):  # test for each sample
          assert_array_equal(vectorised[j], vec_X + j)
  
      ##################################
      # Samples are the last dimension #
      ##################################
      tensor = T.tensor(
          np.concatenate(
              [X[..., None] + i for i in range(n_samples)], axis=-1
          )
      )
      vectorised = partial_tensor_to_vec(
          tensor, skip_end=1, skip_begin=0
      )
      vec_X = tensor_to_vec(T.tensor(X))
      for j in range(n_samples):  # test for each sample
          assert_array_equal(T.transpose(vectorised)[j], vec_X + j)
  
file_path: tensorly/tensorly/tests/test_core.py
imports: import numpy
  from ..None import backend
  from ..base import fold, unfold
  from ..base import partial_fold, partial_unfold
  from ..base import tensor_to_vec, vec_to_tensor
  from ..base import partial_tensor_to_vec, partial_vec_to_tensor
  from ..base import matricize
  from ..testing import assert_array_equal, assert_raises
label_desc: Use image node_id 7 for calling a global function with example usage: test_partial_tensor_to_vec() without return types