code: def save2hdf(input_data, fname, batch_size):
      """Store numpy array to HDF5 file.
  
      Please note chunk size settings in the implementation for I/O performance optimization.
      """
      with h5py.File(fname, "w") as f:
          for name, data in input_data.items():
              nrow, ncol = data.shape
              if ncol == 1:
                  # Y has a single column and we read it in single shot. So store it as an 1-d array.
                  chunk = (nrow,)
                  data = data.values.flatten()
              else:
                  # We use random access for data sampling when creating LightGBM Dataset from Sequence.
                  # When accessing any element in a HDF5 chunk, it's read entirely.
                  # To save I/O for sampling, we should keep number of total chunks much larger than sample count.
                  # Here we are just creating a chunk size that matches with batch_size.
                  #
                  # Also note that the data is stored in row major order to avoid extra copy when passing to
                  # lightgbm Dataset.
                  chunk = (batch_size, ncol)
              f.create_dataset(
                  name, data=data, chunks=chunk, compression="lzf"
              )
  
file_path: LightGBM/examples/python-guide/dataset_from_multi_hdf5.py
imports: from pathlib import Path
  import h5py
  import numpy
  import pandas
  import lightgbm
label_desc: Use image node_id 2 for calling a global function with example usage: save2hdf(input_data, fname, batch_size) without return types