code: def _jit_build_partition_tree(
      xmin,
      xmax,
      ymin,
      ymax,
      zmin,
      zmax,
      total_ywidth,
      total_zwidth,
      M,
      clustering,
      q,
  ):
      """This partitions an image into a herarchical clustering based on axis-aligned splits."""
  
      # heapq.heappush(q, (0, xmin, xmax, ymin, ymax, zmin, zmax, -1, False))
  
      # q.put((0, xmin, xmax, ymin, ymax, zmin, zmax, -1, False))
      ind = len(clustering) - 1
      while len(q) > 0:  # q.empty()
          (
              _,
              xmin,
              xmax,
              ymin,
              ymax,
              zmin,
              zmax,
              parent_ind,
              is_left,
          ) = heapq.heappop(q)
          # _, xmin, xmax, ymin, ymax, zmin, zmax, parent_ind, is_left = q.get()
  
          if parent_ind >= 0:
              clustering[parent_ind, 0 if is_left else 1] = ind + M
  
          # make sure we line up with a flattened indexing scheme
          if ind < 0:
              assert (
                  -ind - 1
                  == xmin * total_ywidth * total_zwidth
                  + ymin * total_zwidth
                  + zmin
              )
  
          xwidth = xmax - xmin
          ywidth = ymax - ymin
          zwidth = zmax - zmin
          if xwidth == 1 and ywidth == 1 and zwidth == 1:
              pass
          else:
              # by default our ranges remain unchanged
              lxmin = rxmin = xmin
              lxmax = rxmax = xmax
              lymin = rymin = ymin
              lymax = rymax = ymax
              lzmin = rzmin = zmin
              lzmax = rzmax = zmax
  
              # split the xaxis if it is the largest dimension
              if xwidth >= ywidth and xwidth > 1:
                  xmid = xmin + xwidth // 2
                  lxmax = xmid
                  rxmin = xmid
  
              # split the yaxis
              elif ywidth > 1:
                  ymid = ymin + ywidth // 2
                  lymax = ymid
                  rymin = ymid
  
              # split the zaxis only when the other ranges are already width 1
              else:
                  zmid = zmin + zwidth // 2
                  lzmax = zmid
                  rzmin = zmid
  
              lsize = (
                  (lxmax - lxmin) * (lymax - lymin) * (lzmax - lzmin)
              )
              rsize = (
                  (rxmax - rxmin) * (rymax - rymin) * (rzmax - rzmin)
              )
  
              heapq.heappush(
                  q,
                  (
                      -lsize,
                      lxmin,
                      lxmax,
                      lymin,
                      lymax,
                      lzmin,
                      lzmax,
                      ind,
                      True,
                  ),
              )
              heapq.heappush(
                  q,
                  (
                      -rsize,
                      rxmin,
                      rxmax,
                      rymin,
                      rymax,
                      rzmin,
                      rzmax,
                      ind,
                      False,
                  ),
              )
              # q.put((-lsize, lxmin, lxmax, lymin, lymax, lzmin, lzmax, ind, True))
              # q.put((-rsize, rxmin, rxmax, rymin, rymax, rzmin, rzmax, ind, False))
  
          ind -= 1
  
      # fill in the group sizes
      for i in range(len(clustering)):
          li = int(clustering[i, 0])
          ri = int(clustering[i, 1])
          lsize = 1 if li < M else clustering[li - M, 3]
          rsize = 1 if ri < M else clustering[ri - M, 3]
          clustering[i, 3] = lsize + rsize
  
file_path: shap/shap/maskers/_image.py
imports: import heapq
  import warnings
  import numba.typed
  import numpy
  from numba import njit
  from numba.core.errors import NumbaPendingDeprecationWarning
  from .._serializable import Deserializer, Serializer
  from ..utils import assert_import, record_import_error, safe_isinstance
  from ..utils._exceptions import DimensionError
  from ._masker import Masker
label_desc: Use image node_id 1 for calling a global function with example usage: _jit_build_partition_tree(xmin, xmax, ymin, ymax, zmin, zmax, total_ywidth, total_zwidth, M, clustering, q) without return types