code: def _create_annotations(any_arr, kind, raw):
      """Create the peak of flat annotations from the any_arr."""
      assert kind in ("peak", "flat")
      starts, stops = _mask_to_onsets_offsets(any_arr)
      starts, stops = np.array(starts), np.array(stops)
      onsets = starts / raw.info["sfreq"]
      durations = (stops - starts) / raw.info["sfreq"]
      annot = Annotations(
          onsets,
          durations,
          [f"BAD_{kind}"] * len(onsets),
          orig_time=raw.info["meas_date"],
      )
      _adjust_onset_meas_date(annot, raw)
      return annot
  
file_path: mne-python/mne/preprocessing/_annotate_amplitude.py
imports: import numpy
  from .._fiff.pick import _picks_by_type, _picks_to_idx
  from ..annotations import Annotations, _adjust_onset_meas_date, _annotations_starts_stops
  from ..fixes import jit
  from ..io import BaseRaw
  from ..utils import _mask_to_onsets_offsets, _validate_type, logger, verbose
label_desc: Use image node_id 7 for calling a global function with example usage: _create_annotations(any_arr, kind, raw) and returns: annot