code: def test_parafac2_to_tensor():
      rng = tl.check_random_state(1234)
      rank = 3
  
      I = 25
      J = 15
      K = 30
  
      weights, factors, projections = random_parafac2(
          shapes=[(J, K)] * I, rank=rank, random_state=rng
      )
  
      constructed_tensor = parafac2_to_tensor(
          (weights, factors, projections)
      )
  
      for i in range(I):
          Bi = T.dot(projections[i], factors[1])
          manual_tensor = T.einsum(
              "r,jr,kr", factors[0][i], Bi, factors[2]
          )
          assert_(
              tl.max(
                  tl.abs(constructed_tensor[i, :, :] - manual_tensor)
              )
              < 1e-6
          )
  
file_path: tensorly/tensorly/decomposition/tests/test_parafac2.py
imports: import itertools
  import numpy
  import pytest
  import tensorly
  from ...random import random_parafac2
  from ...None import backend
  from ...testing import assert_, assert_class_wrapper_correctly_passes_arguments, assert_array_almost_equal, assert_allclose
  from .._parafac2 import Parafac2, parafac2, initialize_decomposition, _BroThesisLineSearch
  from ...parafac2_tensor import Parafac2Tensor, parafac2_to_tensor, parafac2_to_slices
  from ...metrics.factors import congruence_coefficient
label_desc: Use image node_id 10 for calling a global function with example usage: test_parafac2_to_tensor() without return types