code: def test_read_latin1_annotations(tmp_path):
      """Test if annotations encoded as Latin-1 can be read.
  
      Note that the correct encoding according to the EDF+ standard should be
      UTF8, but many real-world files are saved with the Latin-1 encoding.
      """
      annot = (
          b"+1.1\x14\xe9\x14\x00\x00"  # +1.1 é
          b"+1.2\x14\xe0\x14\x00\x00"  # +1.2 à
          b"+1.3\x14\xe8\x14\x00\x00"  # +1.3 è
          b"+1.4\x14\xf9\x14\x00\x00"  # +1.4 ù
          b"+1.5\x14\xe2\x14\x00\x00"  # +1.5 â
          b"+1.6\x14\xea\x14\x00\x00"  # +1.6 ê
          b"+1.7\x14\xee\x14\x00\x00"  # +1.7 î
          b"+1.8\x14\xf4\x14\x00\x00"  # +1.8 ô
          b"+1.9\x14\xfb\x14\x00\x00"  # +1.9 û
      )
      annot_file = tmp_path / "annotations.edf"
      with open(annot_file, "wb") as f:
          f.write(annot)
  
      # Test reading directly from file
      annotations = read_annotations(
          fname=annot_file, encoding="latin1"
      )
      assert_allclose(
          annotations.onset,
          [1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9],
      )
      assert not any(annotations.duration)  # all durations are 0
      assert_array_equal(
          annotations.description,
          ["é", "à", "è", "ù", "â", "ê", "î", "ô", "û"],
      )
  
      # Test reading annotations from channel data
      with open(annot_file, "rb") as f:
          tal_channel = _read_ch(
              f,
              subtype="EDF",
              dtype="<i2",
              samp=-1,
              dtype_byte=None,
          )
      annotations = _read_annotations_edf(
          tal_channel, encoding="latin1"
      )
      assert_allclose(
          annotations.onset,
          [1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9],
      )
      assert not any(annotations.duration)  # all durations are 0
      assert_array_equal(
          annotations.description,
          ["é", "à", "è", "ù", "â", "ê", "î", "ô", "û"],
      )
  
      with pytest.raises(
          Exception, match="Encountered invalid byte in"
      ):
          _read_annotations_edf(
              tal_channel
          )  # default encoding="utf8" fails
      with pytest.raises(
          Exception, match="'utf-8' codec can't decode.*"
      ):
          _read_annotations_edf(str(annot_file))
  
imports: import datetime
  from contextlib import nullcontext
  from functools import partial
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_equal, assert_equal
  from scipy.io import loadmat
  from mne import Annotations, pick_types
  from mne._fiff.pick import channel_indices_by_type, get_channel_type_constants
  from mne.annotations import _ndarray_ch_names, events_from_annotations, read_annotations
  from mne.datasets import testing
  from mne.io import edf, read_raw_bdf, read_raw_edf, read_raw_fif, read_raw_gdf
  from mne.io.edf.edf import _edf_str, _parse_prefilter_string, _read_annotations_edf, _read_ch, _read_edf_header, _read_header
  from mne.io.tests.test_raw import _test_raw_reader
  from mne.tests.test_annotations import _assert_annotations_equal
label_desc: Use image node_id 20 for calling a global function with example usage: test_read_latin1_annotations(tmp_path) without return types