code: def test_plot_annotations(raw, browser_backend):
      """Test annotation mode of the plotter."""
      ismpl = browser_backend.name == "matplotlib"
      with raw.info._unlock():
          raw.info["lowpass"] = 10.0
      _annotation_helper(raw, browser_backend)
      _annotation_helper(raw, browser_backend, events=True)
  
      annot = Annotations([42], [1], "test", raw.info["meas_date"])
      with pytest.warns(RuntimeWarning, match="expanding outside"):
          raw.set_annotations(annot)
      _annotation_helper(raw, browser_backend)
      # test annotation visibility toggle
      fig = raw.plot()
      if ismpl:
          assert len(fig.mne.annotations) == 1
          assert len(fig.mne.annotation_texts) == 1
      else:
          assert len(fig.mne.regions) == 1
      fig._fake_keypress("a")  # start annotation mode
      if ismpl:
          checkboxes = fig.mne.show_hide_annotation_checkboxes
          checkboxes.set_active(0)
          assert len(fig.mne.annotations) == 0
          assert len(fig.mne.annotation_texts) == 0
          checkboxes.set_active(0)
          assert len(fig.mne.annotations) == 1
          assert len(fig.mne.annotation_texts) == 1
      else:
          fig.mne.visible_annotations["test"] = False
          fig._update_regions_visible()
          assert not fig.mne.regions[0].isVisible()
          fig.mne.visible_annotations["test"] = True
          fig._update_regions_visible()
          assert fig.mne.regions[0].isVisible()
  
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 24 for calling a global function with example usage: test_plot_annotations(raw, browser_backend) without return types