code: def test_overlapping_annotation_deletion(
      raw, browser_backend, active_annot_idx
  ):
      """Test deletion of annotations via right-click."""
      ismpl = browser_backend.name == "matplotlib"
      if not ismpl and not check_version("mne_qt_browser", "0.5.2"):
          pytest.xfail("Old mne-qt-browser")
      with raw.info._unlock():
          raw.info["lowpass"] = 10.0
      annot_labels = list("abc")
      # the test applies to the middle three annotations; those before and after are
      # there to ensure our bookkeeping works
      annot = Annotations(
          onset=[3, 3.4, 3.7, 13, 13.4, 13.7, 19, 19.4, 19.7],
          duration=[2, 1, 3] * 3,
          description=annot_labels * 3,
      )
      raw.set_annotations(annot)
      start = 10
      duration = 8
      fig = raw.plot(start=start, duration=duration)
  
      def _get_visible_labels(fig_dot_mne):
          if ismpl:
              # MPL backend's `fig.mne.annotation_texts` → only the visible ones
              visible_labels = [
                  x.get_text() for x in fig_dot_mne.annotation_texts
              ]
          else:
              # PyQtGraph backend's `fig.mne.regions` → all annots (even offscreen ones)
              # so we need to (1) get annotations from fig.mne.inst, and (2) compute
              # ourselves which ones are visible.
              _annot = fig_dot_mne.inst.annotations
              _start = start + fig_dot_mne.inst.first_time
              _end = _start + duration
              visible_indices = np.nonzero(
                  np.logical_and(
                      _annot.onset > _start, _annot.onset < _end
                  )
              )
              visible_labels = np.array(
                  [
                      x.label_item.toPlainText()
                      for x in fig_dot_mne.regions
                  ]
              )[visible_indices].tolist()
          return visible_labels
  
      assert annot_labels == _get_visible_labels(fig.mne)
      fig._fake_keypress("a")  # start annotation mode
      if ismpl:
          buttons = fig.mne.fig_annotation.mne.radio_ax.buttons
          buttons.set_active(active_annot_idx)
          current_active = buttons.value_selected
      else:
          buttons = fig.mne.fig_annotation.description_cmbx
          buttons.setCurrentIndex(active_annot_idx)
          current_active = buttons.currentText()
      assert current_active == annot_labels[active_annot_idx]
      # x value of 14 is in area that overlaps all 3 visible annotations
      fig._fake_click((14, 1.0), xform="data", button=3)
      expected = set(annot_labels) - set(annot_labels[active_annot_idx])
      assert expected == set(_get_visible_labels(fig.mne))
  
imports: import itertools
  import os
  from copy import deepcopy
  import matplotlib.pyplot
  import numpy
  import pytest
  from matplotlib import backend_bases
  from numpy.testing import assert_allclose
  from mne import Annotations, create_info, pick_types
  from mne._fiff.pick import _DATA_CH_TYPES_ORDER_DEFAULT, _PICK_TYPES_DATA_DICT
  from mne.annotations import _sync_onset
  from mne.datasets import testing
  from mne.io import RawArray
  from mne.utils import _assert_no_instances, _dt_to_stamp, _record_warnings, check_version, get_config, set_config
  from mne.viz import plot_raw, plot_sensors
  from mne.viz.utils import _fake_click, _fake_keypress
label_desc: Use image node_id 25 for calling a global function with example usage: test_overlapping_annotation_deletion(raw, browser_backend, active_annot_idx) and returns: visible_labels