code: def test_apply_parafac2_projections():
      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([[1, 0], [0, 1]]),
          tl.tensor([[1, 0], [0, 0], [0, -1]]),
      ]
      true_res = [
          tl.tensor([[7, 4, 4], [8, 2, 2]]),
          tl.tensor([[4, 4, 4], [0, 0, 0], [-2, -2, -2]]),
      ]
  
      new_weights, projected_factors = apply_parafac2_projections(
          (weights, factors, projections)
      )
  
      assert_array_equal(new_weights, weights)
      for i, Bi in enumerate(projected_factors[1]):
          assert_array_almost_equal(
              tl.dot(projections[i], factors[1]), Bi
          )
  
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 7 for calling a global function with example usage: test_apply_parafac2_projections() without return types