code: def test_parafac2_to_tensor():
      weights = tl.tensor([2, 3])
      factors = [
          tl.tensor([[1, 1], [1, 0]]),
          tl.tensor([[2, 1], [1, 2]]),
          tl.tensor([[1, 1], [1, 0], [1, 0]]),
      ]
      projections = [
          tl.tensor([[0, 0], [1, 0], [0, 1]]),
          tl.tensor([[1, 0], [0, 0], [0, -1]]),
      ]
  
      true_res = tl.tensor(
          [
              [[0, 0, 0], [7, 4, 4], [8, 2, 2]],
              [[4, 4, 4], [0, 0, 0], [-2, -2, -2]],
          ]
      )
  
      res = parafac2_to_tensor((weights, factors, projections))
      assert_array_equal(true_res, res)
  
file_path: tensorly/tensorly/tests/test_parafac2_tensor.py
imports: import numpy
  import pytest
  from ..None import backend
  from ..base import unfold, tensor_to_vec
  from ..parafac2_tensor import parafac2_to_tensor, parafac2_to_unfolded, parafac2_to_vec, _validate_parafac2_tensor, parafac2_to_slice, parafac2_to_slices, parafac2_normalise, apply_parafac2_projections
  from ..testing import assert_array_equal, assert_array_almost_equal, assert_equal, assert_raises
  from ..random import random_parafac2
label_desc: Use image node_id 3 for calling a global function with example usage: test_parafac2_to_tensor() without return types