code: def test_annotate_amplitude_with_overlap(meas_date, first_samp):
      """Test cases with overlap between annotations."""
      n_ch, n_times = 11, 1000
      data = np.random.RandomState(0).randn(n_ch, n_times)
      assert not (
          np.diff(data, axis=-1) == 0
      ).any()  # nothing flat at first
      info = create_info(n_ch, 1000.0, "eeg")
      # from annotate_flat: test first_samp != for gh-6295
      raw = RawArray(data, info, first_samp=first_samp)
      raw.info["bads"] = [raw.ch_names[-1]]
      raw.set_meas_date(meas_date)
  
      # -- overlap between peak and flat --
      raw_ = raw.copy()
      raw_._data[0, 800:] = 0.0
      raw_._data[1, 700:900] = np.arange(0, 200 * 10, 10)
      raw_._data[1, 900:] += raw_._data[
          1, 899
      ]  # add offset for next samples
      annots, bads = annotate_amplitude(
          raw_, peak=5, flat=0, bad_percent=25
      )
      assert len(annots) == 2
      assert len(bads) == 0
      # check annotation instance
      assert all(
          annot["description"] in ("BAD_flat", "BAD_peak")
          for annot in annots
      )
      for annot in annots:
          start_idx = 700 if annot["description"] == "BAD_peak" else 800
          stop_idx = 899 if annot["description"] == "BAD_peak" else -1
          _check_annotation(
              raw_, annot, meas_date, first_samp, start_idx, stop_idx
          )
  
      # -- overlap between peak and peak on same channel --
      raw_ = raw.copy()
      raw_._data[0, 700:900] = np.arange(0, 200 * 10, 10)
      raw_._data[0, 800:] = np.arange(1000, 300 * 10, 10)
      annots, bads = annotate_amplitude(
          raw_, peak=5, flat=None, bad_percent=50
      )
      assert len(annots) == 1
      assert len(bads) == 0
      # check annotation instance
      assert annots[0]["description"] == "BAD_peak"
      _check_annotation(raw_, annots[0], meas_date, first_samp, 700, -1)
  
      # -- overlap between flat and flat on different channel --
      raw_ = raw.copy()
      raw_._data[0, 700:900] = 0.0
      raw_._data[1, 800:] = 0.0
      annots, bads = annotate_amplitude(
          raw_, peak=None, flat=0.01, bad_percent=50
      )
      assert len(annots) == 1
      assert len(bads) == 0
      # check annotation instance
      assert annots[0]["description"] == "BAD_flat"
      _check_annotation(raw_, annots[0], meas_date, first_samp, 700, -1)
  
file_path: mne-python/mne/preprocessing/tests/test_annotate_amplitude.py
imports: import datetime
  import itertools
  import re
  from pathlib import Path
  import numpy
  import pytest
  from mne import create_info
  from mne.annotations import Annotations
  from mne.datasets import testing
  from mne.io import RawArray, read_raw_fif
  from mne.preprocessing import annotate_amplitude
label_desc: Use image node_id 2 for calling a global function with example usage: test_annotate_amplitude_with_overlap(meas_date, first_samp) without return types