You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: dataset.rb
    path of file: ./repos/rumale/rumale-core/lib/rumale
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

require 'csv'
require 'numo/narray'
require 'rumale/utils'

module Rumale
  # Module for loading and sa
    
      def load_libsvm_file(filename, n_features: nil, zero_based: false, dtype: Numo::DFloat)
        ftvecs = []
        labels = []
        n_features_detected = 0
        CSV.foreach(filename, col_sep: "\s", headers: false) do |line|
          label, ftvec, max_idx = parse_libsvm_line(line, zero_based)
          labels.push(label)
          ftvecs.push(ftvec)
          n_features_detected = max_idx if n_features_detected < max_idx
        end
        n_features ||= n_features_detected
        n_features = [n_features, n_features_detected].max
        [convert_to_matrix(ftvecs, n_features, dtype), Numo::NArray.asarray(labels)]
      end