code: def test_annotation_duration_setting():
      """Test annotation duration setting works."""
      a = Annotations([1, 2, 3], [5, 5, 8], ["a", "b", "c"])
      assert isinstance(a.duration, np.ndarray)
      assert len(a) == 3
      assert a.duration[0] == 5
      assert a.duration[2] == 8
      a.set_durations({"a": 3})
      assert a.duration[0] == 3
      assert a.duration[2] == 8
      a.set_durations({"a": 313, "c": 18})
      assert a.duration[0] == 313
      assert a.duration[2] == 18
      a.set_durations({"a": 1, "b": 13})
      assert a.duration[0] == 1
      assert a.duration[1] == 13
  
      a = Annotations([1, 2, 3], [5, 5, 8], ["a", "b", "c"])
      assert len(a) == 3
      assert a.duration[0] == 5
      assert a.duration[2] == 8
      a.set_durations(7.2)
      assert isinstance(a.duration, np.ndarray)
      assert a.duration[0] == 7.2
      assert a.duration[2] == 7.2
      a.set_durations(2)
      assert a.duration[0] == 2
  
      with pytest.raises(ValueError, match="not present in data"):
          a.set_durations({"aaa": 2.2})
      with pytest.raises(TypeError, match=" got <class 'set'> instead"):
          a.set_durations({"aaa", 2.2})
  
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 46 for calling a global function with example usage: test_annotation_duration_setting() without return types