code: def load_from_mat(filename, reference):
      mat = np.loadtxt(str(filename), dtype=np.float64)
      label = mat[:, 0].astype(np.float32)
      mat = mat[:, 1:]
      data = np.array(
          mat.reshape(mat.size), dtype=np.float64, copy=False
      )
      handle = ctypes.c_void_p()
      ref = None
      if reference is not None:
          ref = reference
  
      LIB.LGBM_DatasetCreateFromMat(
          data.ctypes.data_as(ctypes.POINTER(ctypes.c_double)),
          ctypes.c_int(dtype_float64),
          ctypes.c_int32(mat.shape[0]),
          ctypes.c_int32(mat.shape[1]),
          ctypes.c_int(1),
          c_str("max_bin=15"),
          ref,
          ctypes.byref(handle),
      )
      num_data = ctypes.c_int(0)
      LIB.LGBM_DatasetGetNumData(handle, ctypes.byref(num_data))
      num_feature = ctypes.c_int(0)
      LIB.LGBM_DatasetGetNumFeature(handle, ctypes.byref(num_feature))
      LIB.LGBM_DatasetSetField(
          handle,
          c_str("label"),
          label.ctypes.data_as(ctypes.POINTER(ctypes.c_float)),
          ctypes.c_int(len(label)),
          ctypes.c_int(dtype_float32),
      )
      print(f"#data: {num_data.value} #feature: {num_feature.value}")
      return handle
  
file_path: LightGBM/tests/c_api_test/test_.py
imports: import ctypes
  from pathlib import Path
  from platform import system
  import numpy
  from scipy import sparse
label_desc: Use image node_id 6 for calling a global function with example usage: load_from_mat(filename, reference) and returns: handle