code: def perform_expansion(
      indptr,
      indices,
      data,
      expanded_data,
      expanded_indices,
      d,
      interaction_only,
      degree,
      expanded_indptr,
  ):
      """Kernel applying polynomial expansion on CSR matrix"""
      row_i = cuda.blockIdx.x * cuda.blockDim.x + cuda.threadIdx.x
      inrow_idx = cuda.blockIdx.y * cuda.blockDim.y + cuda.threadIdx.y
  
      if row_i >= indptr.shape[0] - 1:
          return
  
      expanded_index = expanded_indptr[row_i] + inrow_idx
      if expanded_index >= expanded_indptr[row_i + 1]:
          return
  
      row_starts = indptr[row_i]
      row_ends = indptr[row_i + 1]
  
      i_ptr = row_starts
      j_ptr = -1
      k_ptr = inrow_idx
  
      if degree == 2:
          j_ptr = inrow_idx
          for i in range(row_starts, row_ends):
              diff = row_ends - i - interaction_only
              if j_ptr >= diff:
                  j_ptr -= diff
              else:
                  i_ptr = i
                  break
          j_ptr += i_ptr + interaction_only
      else:
          # degree == 3
          diff = 0
          for i in range(row_starts, row_ends):
              for j in range(i + interaction_only, row_ends):
                  diff = row_ends - j - interaction_only
                  if k_ptr >= diff:
                      k_ptr -= diff
                  else:
                      j_ptr = j
                      i_ptr = i
                      break
              if j_ptr != -1:
                  break
  
          k_ptr += j_ptr + interaction_only
  
      i = indices[i_ptr]
      j = indices[j_ptr]
  
      if degree == 2:
          col = _deg2_column(d, i, j, interaction_only)
          expanded_indices[expanded_index] = col
          expanded_data[expanded_index] = data[i_ptr] * data[j_ptr]
      else:
          # degree == 3
          k = indices[k_ptr]
          col = _deg3_column(d, i, j, k, interaction_only)
          expanded_indices[expanded_index] = col
          expanded_data[expanded_index] = (
              data[i_ptr] * data[j_ptr] * data[k_ptr]
          )
  
file_path: cuml/python/cuml/thirdparty_adapters/sparsefuncs_fast.py
imports: from math import ceil
  from cuml.internals.safe_imports import gpu_only_import_from
  from cuml.internals.safe_imports import gpu_only_import
label_desc: Use image node_id 11 for calling a global function with example usage: perform_expansion(indptr, indices, data, expanded_data, expanded_indices, d, interaction_only, degree, expanded_indptr) without return types