code: def _select_by_peak_threshold(x, peaks, tmin, tmax):
      """
      Evaluate which peaks fulfill the threshold condition.
  
      Parameters
      ----------
      x : ndarray
          A 1-D array which is indexable by `peaks`.
      peaks : ndarray
          Indices of peaks in `x`.
      tmin, tmax : scalar or ndarray or None
           Minimal and / or maximal required thresholds. If supplied as ndarrays
           their size must match `peaks`. ``None`` is interpreted as an open
           border.
  
      Returns
      -------
      keep : bool
          A boolean mask evaluating to true where `peaks` fulfill the threshold
          condition.
      left_thresholds, right_thresholds : ndarray
          Array matching `peak` containing the thresholds of each peak on
          both sides.
  
      """
      # Stack thresholds on both sides to make min / max operations easier:
      # tmin is compared with the smaller, and tmax with the greater thresold to
      # each peak's side
      stacked_thresholds = cupy.vstack(
          [x[peaks] - x[peaks - 1], x[peaks] - x[peaks + 1]]
      )
      keep = cupy.ones(peaks.size, dtype=bool)
      if tmin is not None:
          min_thresholds = cupy.min(stacked_thresholds, axis=0)
          keep &= tmin <= min_thresholds
      if tmax is not None:
          max_thresholds = cupy.max(stacked_thresholds, axis=0)
          keep &= max_thresholds <= tmax
  
      return keep, stacked_thresholds[0], stacked_thresholds[1]
  
imports: import math
  import cupy
  from cupy._core._scalar import get_typename
  from cupy_backends.cuda.api import runtime
  from cupyx import jit
label_desc: Use image node_id 6 for calling a global function with example usage: _select_by_peak_threshold(x, peaks, tmin, tmax) and returns: keep,  stacked_thresholds,  stacked_thresholds