code: def test_cp_mode_dot():
      """Test for cp_mode_dot
  
      We will compare cp_mode_dot
      (which operates directly on decomposed tensors)
      with mode_dot (which operates on full tensors)
      and check that the results are the same.
      """
      rng = tl.check_random_state(12345)
      shape = (5, 4, 6)
      rank = 3
      cp_ten = random_cp(shape, rank=rank, orthogonal=True, full=False)
      full_tensor = tl.cp_to_tensor(cp_ten)
      # matrix for mode 1
      matrix = tl.tensor(rng.random_sample((7, shape[1])))
      # vec for mode 2
      vec = tl.tensor(rng.random_sample(shape[2]))
  
      # Test cp_mode_dot with matrix
      res = cp_mode_dot(cp_ten, matrix, mode=1, copy=True)
      # Note that if copy=True is not respected, factors will be changes
      # And the next test will fail
      res = tl.cp_to_tensor(res)
      true_res = mode_dot(full_tensor, matrix, mode=1)
      assert_array_almost_equal(true_res, res)
  
      # Check that the data was indeed copied
      rec = tl.cp_to_tensor(cp_ten)
      assert_array_almost_equal(full_tensor, rec)
  
      # Test cp_mode_dot with vec
      res = cp_mode_dot(cp_ten, vec, mode=2, copy=True)
      res = tl.cp_to_tensor(res)
      true_res = mode_dot(full_tensor, vec, mode=2)
      assert_equal(res.shape, true_res.shape)
      assert_array_almost_equal(true_res, res)
  
imports: import numpy
  import tensorly
  from ..tenalg import khatri_rao, mode_dot
  from ..cp_tensor import cp_to_tensor, cp_to_unfolded, cp_to_vec, _validate_cp_tensor, cp_normalize, CPTensor, cp_mode_dot, cp_norm, cp_flip_sign, _cp_n_param, validate_cp_rank, cp_lstsq_grad, cp_permute_factors
  from ..base import unfold, tensor_to_vec
  from tensorly.random import random_cp
  from tensorly.testing import assert_equal, assert_raises, assert_, assert_array_equal, assert_array_almost_equal
  import pytest
label_desc: Use image node_id 8 for calling a global function with example usage: test_cp_mode_dot() without return types