code: def test_unfold():
      """Test for unfold
  
      1. We do an exact test.
  
      2. Second,  a test inspired by the example in Kolda's paper:
         Even though we use a different definition of the unfolding,
         it should only differ by the ordering of the columns
      """
      X = T.tensor(
          [
              [[1, 13], [4, 16], [7, 19], [10, 22]],
              [[2, 14], [5, 17], [8, 20], [11, 23]],
              [[3, 15], [6, 18], [9, 21], [12, 24]],
          ]
      )
  
      X = T.reshape(T.arange(24), (3, 4, 2))
      unfoldings = [
          T.tensor(
              [
                  [0, 1, 2, 3, 4, 5, 6, 7],
                  [8, 9, 10, 11, 12, 13, 14, 15],
                  [16, 17, 18, 19, 20, 21, 22, 23],
              ]
          ),
          T.tensor(
              [
                  [0, 1, 8, 9, 16, 17],
                  [2, 3, 10, 11, 18, 19],
                  [4, 5, 12, 13, 20, 21],
                  [6, 7, 14, 15, 22, 23],
              ]
          ),
          T.tensor(
              [
                  [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22],
                  [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23],
              ]
          ),
      ]
      for mode in range(T.ndim(X)):
          unfolding = unfold(X, mode=mode)
          assert_array_equal(unfolding, unfoldings[mode])
          assert_array_equal(
              T.reshape(unfolding, (-1,)),
              T.reshape(unfoldings[mode], (-1,)),
          )
  
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 1 for calling a global function with example usage: test_unfold() without return types