code: def _find_shapelet_quality(
      X,
      y,
      shapelet,
      sorted_indices,
      position,
      length,
      dim,
      inst_idx,
      this_cls_count,
      other_cls_count,
      worst_quality,
  ):
      # todo optimise this more, we spend 99% of time here
      orderline = []
      this_cls_traversed = 0
      other_cls_traversed = 0
  
      for i, series in enumerate(X):
          if i != inst_idx:
              distance = _online_shapelet_distance(
                  series[dim],
                  shapelet,
                  sorted_indices,
                  position,
                  length,
              )
          else:
              distance = 0
  
          if y[i] == y[inst_idx]:
              cls = 1
              this_cls_traversed += 1
          else:
              cls = -1
              other_cls_traversed += 1
  
          orderline.append((distance, cls))
          orderline.sort()
  
          if worst_quality > 0:
              quality = _calc_early_binary_ig(
                  orderline,
                  this_cls_traversed,
                  other_cls_traversed,
                  this_cls_count - this_cls_traversed,
                  other_cls_count - other_cls_traversed,
                  worst_quality,
              )
  
              if quality <= worst_quality:
                  return -1
  
      quality = _calc_binary_ig(
          orderline, this_cls_count, other_cls_count
      )
  
      return round(quality, 12)
  
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 6 for calling a global function with example usage: _find_shapelet_quality(X, y, shapelet, sorted_indices, position, length, dim, inst_idx, this_cls_count, other_cls_count, worst_quality) and returns: round, unknown