code: def kernel_custom(dim=7):
      from numpy.random import rand, seed
      from numpy import array, float32, int32
      from shogun import CustomKernel
      from shogun import IndexFeatures
      import shogun as sg
  
      seed(17)
      data = rand(dim, dim)
      feats = sg.create_features(data)
      symdata = data + data.T
      lowertriangle = array(
          [
              symdata[(x, y)]
              for x in range(symdata.shape[1])
              for y in range(symdata.shape[0])
              if y <= x
          ]
      )
  
      kernel = CustomKernel()
  
      # once with float64's
      kernel.set_triangle_kernel_matrix_from_triangle(lowertriangle)
      km_triangletriangle = kernel.get_kernel_matrix()
  
      kernel.set_triangle_kernel_matrix_from_full(symdata)
      km_fulltriangle = kernel.get_kernel_matrix()
  
      kernel.set_full_kernel_matrix_from_full(symdata)
      km_fullfull = kernel.get_kernel_matrix()
  
      # get subset of kernel
      row_idx = array(range(3), dtype=int32)
      col_idx = array(range(2), dtype=int32)
      row_idx_feat = IndexFeatures(row_idx)
      col_idx_feat = IndexFeatures(col_idx)
      kernel.init(row_idx_feat, col_idx_feat)
      km_sub_kernel = kernel.get_kernel_matrix()
      # print('Subkernel(3x2):\n%s'%km_sub_kernel)
      kernel.remove_all_col_subsets()
      kernel.remove_all_row_subsets()
  
      # now once with float32's
      data = array(data, dtype=float32)
  
      kernel.set_triangle_kernel_matrix_from_triangle(lowertriangle)
      km_triangletriangle = kernel.get_kernel_matrix()
  
      kernel.set_triangle_kernel_matrix_from_full(symdata)
      km_fulltriangle = kernel.get_kernel_matrix()
  
      kernel.set_full_kernel_matrix_from_full(symdata)
      km_fullfull = kernel.get_kernel_matrix()
      return km_fullfull, kernel, km_sub_kernel
  
label_desc: Use image node_id 1 for calling a global function with example usage: kernel_custom(dim) and returns: km_fullfull,  kernel,  km_sub_kernel