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: extra_tree_regressor.rb
    path of file: ./repos/rumale/rumale-tree/lib/rumale/tree
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

require 'rumale/tree/decision_tree_regressor'

module Rumale
  module Tree
    # ExtraTreeRegressor is a class that implements
    
      def best_split(features, y, whole_impurity)
        threshold = @sub_rng.rand(features.min..features.max)
        l_ids = features.le(threshold).where
        r_ids = features.gt(threshold).where
        l_impurity = l_ids.empty? ? 0.0 : impurity(y[l_ids, true])
        r_impurity = r_ids.empty? ? 0.0 : impurity(y[r_ids, true])
        gain = whole_impurity -
               l_impurity * l_ids.size.fdiv(y.shape[0]) -
               r_impurity * r_ids.size.fdiv(y.shape[0])
        [l_impurity, r_impurity, threshold, gain]
      end