code: def step_impurity(
      thresholds,
      data: np.ndarray,
      labels: np.ndarray,
      classes: Optional[List[int]] = None,
  ) -> float:
      """
      Calculate the step-wise Gini impurity of a dataset split on a set of thresholds.
  
      Args:
          thresholds (np.ndarray): The thresholds to split the data on.
          data (np.ndarray): The data to split.
          labels (np.ndarray): The labels for the data.
          classes (Optional[List[int]]): The classes to consider. If None, all classes are used.
  
      Returns:
          float: The step-wise Gini impurity.
      """
      G = gini_impurity(
          thresholds, data, labels, reduction=None, classes=classes
      )
      out = []
      for i in range(len(G) - 1):
          out.append(G[i] + G[i + 1])
      return out
  
imports: from collections import deque
  import operator
  import itertools
  from typing import Optional, List, Tuple
  import numpy
  import warnings
label_desc: Use image node_id 5 for calling a global function with example usage: step_impurity(thresholds, data, labels, classes) and returns: out