code: def _calc_early_binary_ig(
      orderline,
      c1_traversed,
      c2_traversed,
      c1_to_add,
      c2_to_add,
      worst_quality,
  ):
      initial_ent = _binary_entropy(
          c1_traversed + c1_to_add,
          c2_traversed + c2_to_add,
      )
  
      total_all = c1_traversed + c2_traversed + c1_to_add + c2_to_add
  
      bsf_ig = 0
      # actual observations in orderline
      c1_count = 0
      c2_count = 0
  
      # evaluate each split point
      for split in range(len(orderline)):
          next_class = orderline[split][
              1
          ]  # +1 if this class, -1 if other
          if next_class > 0:
              c1_count += 1
          else:
              c2_count += 1
  
          # optimistically add this class to left side first and other to right
          left_prop = (split + 1 + c1_to_add) / total_all
          ent_left = _binary_entropy(c1_count + c1_to_add, c2_count)
  
          # because right side must optimistically contain everything else
          right_prop = 1 - left_prop
  
          ent_right = _binary_entropy(
              c1_traversed - c1_count,
              c2_traversed - c2_count + c2_to_add,
          )
  
          ig = (
              initial_ent
              - left_prop * ent_left
              - right_prop * ent_right
          )
          bsf_ig = max(ig, bsf_ig)
  
          # now optimistically add this class to right, other to left
          left_prop = (split + 1 + c2_to_add) / total_all
          ent_left = _binary_entropy(c1_count, c2_count + c2_to_add)
  
          # because right side must optimistically contain everything else
          right_prop = 1 - left_prop
  
          ent_right = _binary_entropy(
              c1_traversed - c1_count + c1_to_add,
              c2_traversed - c2_count,
          )
  
          ig = (
              initial_ent
              - left_prop * ent_left
              - right_prop * ent_right
          )
          bsf_ig = max(ig, bsf_ig)
  
          if bsf_ig > worst_quality:
              return bsf_ig
  
      return bsf_ig
  
file_path: sktime/sktime/transformations/panel/_shapelet_transform_numba.py
imports: import heapq
  import math
  import numpy
  from sktime.utils.numba.njit import njit
label_desc: Use image node_id 2 for calling a global function with example usage: _calc_early_binary_ig(orderline, c1_traversed, c2_traversed, c1_to_add, c2_to_add, worst_quality) and returns: bsf_ig, bsf_ig