code: def best_split_original(tree, X, y):
      """Find the best split for a node."""
      # Need at least two elements to split a node.
      m = y.size
      if m <= 1:
          return None, None
  
      # Count of each class in the current node.
      num_parent = [np.sum(y == c) for c in range(tree.n_classes_)]
  
      # Gini of current node.
      best_gini = 1.0 - sum((n / m) ** 2 for n in num_parent)
      best_idx, best_thr = None, None
  
      # Loop through all features.
      for idx in range(tree.n_features_):
          # Sort data along selected feature.
          thresholds, classes = zip(*sorted(zip(X[:, idx], y)))
          # print("Classes are: ", classes, " ", thresholds)
          # We could actually split the node according to each feature/threshold
          # and count the resulting population for each class in the children,
          # instead we compute them in an iterative fashion, making this for loop
          # linear rather than quadratic.
          num_left = [0] * tree.n_classes_
          num_right = num_parent.copy()
          for i in range(1, m):  # possible split positions
              c = classes[i - 1]
              # print("c is ", c, "num left is", len(num_left))
              num_left[c] += 1
              num_right[c] -= 1
              gini_left = 1.0 - sum(
                  (num_left[x] / i) ** 2 for x in range(tree.n_classes_)
              )
              gini_right = 1.0 - sum(
                  (num_right[x] / (m - i)) ** 2
                  for x in range(tree.n_classes_)
              )
  
              # The Gini impurity of a split is the weighted average of the Gini
              # impurity of the children.
              gini = (i * gini_left + (m - i) * gini_right) / m
  
              # The following condition is to make sure we don't try to split two
              # points with identical values for that feature, as it is impossibl
              # (both have to end up on the same side of a split).
              if thresholds[i] == thresholds[i - 1]:
                  continue
  
              if gini < best_gini:
                  best_gini = gini
                  best_idx = idx
                  best_thr = (
                      thresholds[i] + thresholds[i - 1]
                  ) / 2  # midpoint
  
      return best_idx, best_thr
  
imports: import numpy
  import ray
  from sklearn import datasets, metrics
  import time
  import tempfile
  import os
  import json
label_desc: Use image node_id 3 for calling a global function with example usage: best_split_original(tree, X, y) and returns: best_idx,  best_thr, None,  None