code: def _read_mrk(fname):
      """Read annotations from a vmrk/amrk file.
  
      Parameters
      ----------
      fname : str
          vmrk/amrk file to be read.
  
      Returns
      -------
      onset : array, shape (n_annots,)
          The onsets in seconds.
      duration : array, shape (n_annots,)
          The onsets in seconds.
      description : array, shape (n_annots,)
          The description of each annotation.
      date_str : str
          The recording time as a string. Defaults to empty string if no
          recording time is found.
      """
      # read marker file
      with open(fname, "rb") as fid:
          txt = fid.read()
  
      # we don't actually need to know the coding for the header line.
      # the characters in it all belong to ASCII and are thus the
      # same in Latin-1 and UTF-8
      header = txt.decode("ascii", "ignore").split("\n")[0].strip()
      _check_bv_version(header, "marker")
  
      # although the markers themselves are guaranteed to be ASCII (they
      # consist of numbers and a few reserved words), we should still
      # decode the file properly here because other (currently unused)
      # blocks, such as that the filename are specifying are not
      # guaranteed to be ASCII.
  
      try:
          # if there is an explicit codepage set, use it
          # we pretend like it's ascii when searching for the codepage
          cp_setting = re.search(
              "Codepage=(.+)",
              txt.decode("ascii", "ignore"),
              re.IGNORECASE & re.MULTILINE,
          )
          codepage = "utf-8"
          if cp_setting:
              codepage = cp_setting.group(1).strip()
          # BrainAmp Recorder also uses ANSI codepage
          # an ANSI codepage raises a LookupError exception
          # python recognize ANSI decoding as cp1252
          if codepage == "ANSI":
              codepage = "cp1252"
          txt = txt.decode(codepage)
      except UnicodeDecodeError:
          # if UTF-8 (new standard) or explicit codepage setting fails,
          # fallback to Latin-1, which is Windows default and implicit
          # standard in older recordings
          txt = txt.decode("latin-1")
  
      # extract Marker Infos block
      m = re.search(r"\[Marker Infos\]", txt, re.IGNORECASE)
      if not m:
          return (
              np.array(list()),
              np.array(list()),
              np.array(list()),
              "",
          )
  
      mk_txt = txt[m.end() :]
      m = re.search(r"^\[.*\]$", mk_txt)
      if m:
          mk_txt = mk_txt[: m.start()]
  
      # extract event information
      items = re.findall(r"^Mk\d+=(.*)", mk_txt, re.MULTILINE)
      onset, duration, description = list(), list(), list()
      date_str = ""
      for info in items:
          info_data = info.split(",")
          mtype, mdesc, this_onset, this_duration = info_data[:4]
          # commas in mtype and mdesc are handled as "\1". convert back to comma
          mtype = mtype.replace(r"\1", ",")
          mdesc = mdesc.replace(r"\1", ",")
          if (
              date_str == ""
              and len(info_data) == 5
              and mtype == "New Segment"
          ):
              # to handle the origin of time and handle the presence of multiple
              # New Segment annotations. We only keep the first one that is
              # different from an empty string for date_str.
              date_str = info_data[-1]
  
          this_duration = (
              int(this_duration) if this_duration.isdigit() else 0
          )
          duration.append(this_duration)
          onset.append(
              int(this_onset) - 1
          )  # BV is 1-indexed, not 0-indexed
          description.append(mtype + "/" + mdesc)
  
      return (
          np.array(onset),
          np.array(duration),
          np.array(description),
          date_str,
      )
  
imports: import configparser
  import os
  import os.path
  import re
  from datetime import datetime, timezone
  from io import StringIO
  import numpy
  from ..._fiff.constants import FIFF
  from ..._fiff.meas_info import _empty_info
  from ..._fiff.utils import _mult_cal_one, _read_segments_file
  from ...annotations import Annotations, read_annotations
  from ...channels import make_dig_montage
  from ...defaults import HEAD_SIZE_DEFAULT
  from ...transforms import _sph_to_cart
  from ...utils import _DefaultEventParser, fill_doc, logger, verbose, warn
  from ..base import BaseRaw
label_desc: Use image node_id 2 for calling a global function with example usage: _read_mrk(fname) and returns: np,  np,  np,  date_str, np,  np,  np,  str