code: def test_sample_khatri_rao():
      """Test for sample_khatri_rao"""
      rng = tl.check_random_state(1234)
      t_shape = (8, 9, 10)
      rank = 3
      _, factors = random_cp(t_shape, rank, full=False)
      num_samples = 4
      skip_matrix = 1
      sampled_kr, _, sampled_rows = sample_khatri_rao(
          factors,
          num_samples,
          skip_matrix=skip_matrix,
          return_sampled_rows=True,
          random_state=rng,
      )
      assert_(
          T.shape(sampled_kr) == (num_samples, rank),
          "Sampled shape of khatri-rao product is inconsistent",
      )
      assert_(
          np.max(sampled_rows) < (t_shape[0] * t_shape[2]),
          "Largest sampled row index is bigger than number of columns of"
          "unfolded matrix",
      )
      assert_(
          np.min(sampled_rows) >= 0,
          "Smallest sampled row index index is smaller than 0",
      )
      true_kr = khatri_rao(factors, skip_matrix=skip_matrix)
      for ix, j in enumerate(sampled_rows):
          assert_array_equal(
              true_kr[j],
              sampled_kr[int(ix)],
              err_msg="Sampled khatri_rao product doesnt correspond to product",
          )
  
imports: import numpy
  import pytest
  import tensorly
  from .._cp import parafac, initialize_cp, sample_khatri_rao, randomised_parafac, CP, RandomizedCP, CPTensor
  from .._nn_cp import non_negative_parafac, non_negative_parafac_hals, CP_NN, CP_NN_HALS
  from ...cp_tensor import cp_to_tensor
  from ...cp_tensor import cp_to_tensor
  from ...random import random_cp
  from ...tenalg import khatri_rao
  from ...None import backend
  from ...testing import assert_array_equal, assert_, assert_class_wrapper_correctly_passes_arguments, assert_array_almost_equal
  from ...metrics.factors import congruence_coefficient
label_desc: Use image node_id 7 for calling a global function with example usage: test_sample_khatri_rao() without return types