code: def labels_to_ranges_numba(labels: np.ndarray) -> List[Tuple]:
      """
      Converts the given list of labels to list of anomaly (defined by positive
      label) ranges where range is represented by a pair of integers (to make
      numba work).
  
      Parameters
      ----------
      labels
          Boolean list of labels.
  
      Returns
      -------
      List of ranges.
      """
  
      ranges_ls = []
      start_ix = None
      stop_ix = None
      for ix, label in enumerate(labels):
          if label:
              # this might be the last positive label in the anomaly range
              stop_ix = ix + 1
              if start_ix is None:
                  # a new positive label is seen
                  start_ix = ix
          elif start_ix is not None:
              # a consecutive sequence of positive labels is ended
              assert stop_ix is not None
              ranges_ls.append((start_ix, stop_ix))
              start_ix = None
  
      if start_ix is not None:
          # the last element of `labels` is True, we never ended that range
          assert stop_ix is not None
          ranges_ls.append((start_ix, stop_ix))
  
      return ranges_ls
  
imports: from typing import List, Tuple
  import numpy
  from numba import jit
label_desc: Use image node_id 2 for calling a global function with example usage: labels_to_ranges_numba(labels) and returns: ranges_ls