code: def sample_khatri_rao(
      matrices,
      n_samples,
      skip_matrix=None,
      indices_list=None,
      return_sampled_rows=False,
      random_state=None,
  ):
      """Random subsample of the Khatri-Rao product of the given list of matrices
  
          If one matrix only is given, that matrix is directly returned.
  
      Parameters
      ----------
      matrices : ndarray list
          list of matrices with the same number of columns, i.e.::
  
              for i in len(matrices):
                  matrices[i].shape = (n_i, m)
  
      n_samples : int
          number of samples to be taken from the Khatri-Rao product
  
      skip_matrix : None or int, optional, default is None
          if not None, index of a matrix to skip
  
      indices_list : list, default is None
          Contains, for each matrix in `matrices`, a list of indices of rows to sample.
          if None, random indices will be created
  
      random_state : None, int or numpy.random.RandomState
          if int, used to set the seed of the random number generator
          if numpy.random.RandomState, used to generate random_samples
  
      returned_sampled_rows : bool, default is False
          if True, also returns a list of the rows sampled from the full
          khatri-rao product
  
      Returns
      -------
      sampled_Khatri_Rao : ndarray
          The sampled matricised tensor Khatri-Rao with `n_samples` rows
  
      indices : tuple list
          a list of indices sampled for each mode
  
      indices_kr : int list
          list of length `n_samples` containing the sampled row indices
      """
      if skip_matrix is not None:
          matrices = [
              matrices[i]
              for i in range(len(matrices))
              if i != skip_matrix
          ]
  
      # For each matrix, randomly choose n_samples indices for which to compute the khatri-rao product
      if indices_list is None:
          if random_state is None or not isinstance(
              random_state, np.random.RandomState
          ):
              rng = tl.check_random_state(random_state)
              warnings.warn(
                  "You are creating a new random number generator at each call.\n"
                  "If you are calling sample_khatri_rao inside a loop this will be slow:"
                  " best to create a rng outside and pass it as argument (random_state=rng)."
              )
          else:
              rng = random_state
          indices_list = [
              rng.randint(0, tl.shape(m)[0], size=n_samples, dtype=int)
              for m in matrices
          ]
  
      rank = tl.shape(matrices[0])[1]
      sizes = [tl.shape(m)[0] for m in matrices]
  
      if return_sampled_rows:
          # Compute corresponding rows of the full khatri-rao product
          indices_kr = np.zeros((n_samples), dtype=int)
          for size, indices in zip(sizes, indices_list):
              indices_kr = indices_kr * size + indices
  
      # Compute the Khatri-Rao product for the chosen indices
      sampled_kr = tl.ones((n_samples, rank), **tl.context(matrices[0]))
      for indices, matrix in zip(indices_list, matrices):
          sampled_kr = sampled_kr * matrix[indices, :]
  
      if return_sampled_rows:
          return sampled_kr, indices_list, indices_kr
      else:
          return sampled_kr, indices_list
  
imports: import numpy
  import warnings
  import tensorly
  from ._base_decomposition import DecompositionMixin
  from ..random import random_cp
  from ..base import unfold
  from ..cp_tensor import cp_to_tensor, CPTensor, cp_norm, cp_normalize, validate_cp_rank
  from ..tenalg.svd import svd_interface
  from ..tenalg import unfolding_dot_khatri_rao
label_desc: Use image node_id 5 for calling a global function with example usage: sample_khatri_rao(matrices, n_samples, skip_matrix, indices_list, return_sampled_rows, random_state) and returns: sampled_kr,  indices_list,  indices_kr, sampled_kr,  indices_list