class_docstr: Alternating Least Square to solve Canonical Polyadic Decompositon.
  
      
docstr: Column-wise Khatri-Rao product.
  
  Khatri-Rao product is the column-wise matching Kroncker product.
  For examples, suppose matrices X and Y each of which dimensions
  is (I, K) and (J, K).
  
  Khatri-Rao product between X and Y is defined by
  
  .. math::
  
      X \odot Y = [a_1 \otimes b_1   a_2 \otimes b_2  \ldots a_K \otimes b_K ].
  
  
  Khatri-Rao product usually returns a matrix, or 2-dimensional array,
  but in this function, it returns 3-dimensional array for the next use for
  tensor-dot product efficiently.
  
  Args:
      X (numpy.ndarray): the matrix which the number of the columns is the same as Y's.
      Y (numpy.ndarray): the matrix which the number of the columns is the same as X's.
  
  Returns:
      numpy.ndarray: the 3-dimensional array with the shape (I x J x K).
docstr_tok: ["Column-wise","Khatri-Rao","product",".","Khatri-Rao","product","is","the","column-wise","matching","Kroncker","product",".","For","examples",",","suppose","matrices","X","and","Y","each","of","which","dimensions","is","(","I",",","K",")","and","(","J",",","K",")",".","Khatri-Rao","product","between","X","and","Y","is","defined","by","..","math",":",":","X","\\odot","Y","=","[","a_1","\\otimes","b_1","a_2","\\otimes","b_2","\\ldots","a_K","\\otimes","b_K","]",".","Khatri-Rao","product","usually","returns","a","matrix",",","or","2-dimensional","array",",","but","in","this","function",",","it","returns","3-dimensional","array","for","the","next","use","for","tensor-dot","product","efficiently",".","Args",":","X","(","numpy.ndarray",")",":","the","matrix","which","the","number","of","the","columns","is","the","same","as","Y","'s",".","Y","(","numpy.ndarray",")",":","the","matrix","which","the","number","of","the","columns","is","the","same","as","X","'s",".","Returns",":","numpy.ndarray",":","the","3-dimensional","array","with","the","shape","(","I","x","J","x","K",")","."]
code: def khatrirao_product(self, X, Y):
      """Column-wise Khatri-Rao product.
  
      Khatri-Rao product is the column-wise matching Kroncker product.
      For examples, suppose matrices X and Y each of which dimensions
      is (I, K) and (J, K).
  
      Khatri-Rao product between X and Y is defined by
  
      .. math::
  
          X \odot Y = [a_1 \otimes b_1   a_2 \otimes b_2  \ldots a_K \otimes b_K ].
  
  
      Khatri-Rao product usually returns a matrix, or 2-dimensional array,
      but in this function, it returns 3-dimensional array for the next use for
      tensor-dot product efficiently.
  
      Args:
          X (numpy.ndarray): the matrix which the number of the columns is the same as Y's.
          Y (numpy.ndarray): the matrix which the number of the columns is the same as X's.
  
      Returns:
          numpy.ndarray: the 3-dimensional array with the shape (I x J x K).
  
      """
  
      n_cols = X.shape[1]
      P = np.zeros((X.shape[0], Y.shape[0], n_cols))
      for r in range(n_cols):
          outer_product = np.outer(X[:, r], Y[:, r])  # TODO: dimension
          P[:, :, r] = outer_product
  
      #         # Multi-thread
      #         def outer_prod(X, Y, r, P):
      #             P[:, :, r] = np.outer(X[:, r], Y[:, r])
      #             return None
      #         future_list = []
      #         for r in range(n_cols):
      #             outer_product = np.outer(X[:, r], Y[:, r])  #TODO: dimension
      #             P[:, :, r] = outer_product
      #             future = self.pool.apply_async(outer_prod, (X, Y, r, P))
      #             future_list.append(future)
      #         for r in range(n_cols):
      #             future_list[r].get()
  
      return P
  
file_path: nnabla/python/src/nnabla/utils/factorization/cpd.py
imports: from functools import reduce
  import numpy
  from scipy.linalg import pinv
label_desc: Use image node_id 3 for calling the ALS obj's underlying member method code with example usage: obj.khatrirao_product(X, Y) and returns: P