code: def test_annotation_ch_names():
      """Test annotation ch_names updating and pruning."""
      info = create_info(10, 1000.0, "eeg")
      raw = RawArray(np.zeros((10, 1000)), info)
      onset = [0.1, 0.3, 0.6]
      duration = [0.05, 0.1, 0.2]
      description = ["first", "second", "third"]
      ch_names = [[], raw.ch_names[4:6], raw.ch_names[5:7]]
      annot = Annotations(
          onset, duration, description, ch_names=ch_names
      )
      raw.set_annotations(annot)
      # renaming
      rename = {name: name + "new" for name in raw.ch_names}
      raw_2 = raw.copy().rename_channels(rename)
      for ch_rename, ch in zip(
          raw_2.annotations.ch_names, annot.ch_names
      ):
          assert all(name in raw_2.ch_names for name in ch_rename)
          assert all(name in raw.ch_names for name in ch)
          assert not any(name in raw.ch_names for name in ch_rename)
          assert not any(name in raw_2.ch_names for name in ch)
      raw_2.rename_channels({val: key for key, val in rename.items()})
      _assert_annotations_equal(raw.annotations, raw_2.annotations)
      # dropping
      raw_2.drop_channels(raw.ch_names[5:])
      annot_pruned = raw_2.annotations
      assert len(raw_2.annotations) == 2  # dropped the last one
      assert raw_2.annotations.ch_names[1] == tuple(raw.ch_names[4:5])
      for ch_drop in raw_2.annotations.ch_names:
          assert all(name in raw_2.ch_names for name in ch_drop)
      with pytest.raises(
          ValueError, match="channel name in annotations missing"
      ):
          raw_2.set_annotations(annot)
      with pytest.warns(
          RuntimeWarning, match="channel name in annotations missing"
      ):
          raw_2.set_annotations(annot, on_missing="warn")
      assert raw_2.annotations is not annot_pruned
      _assert_annotations_equal(raw_2.annotations, annot_pruned)
  
imports: import sys
  from collections import OrderedDict
  from datetime import datetime, timedelta, timezone
  from itertools import repeat
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_equal
  from pytest import approx
  import mne
  from mne import Annotations, Epochs, annotations_from_events, count_annotations, create_info, events_from_annotations, read_annotations
  from mne.annotations import _handle_meas_date, _read_annotations_txt_parse_header, _sync_onset
  from mne.datasets import testing
  from mne.io import RawArray, concatenate_raws, read_raw_fif
  from mne.utils import _dt_to_stamp, _raw_annot, _record_warnings, _stamp_to_dt, assert_and_remove_boundary_annot, catch_logging, check_version
label_desc: Use image node_id 44 for calling a global function with example usage: test_annotation_ch_names() without return types