code: def _read_events_fif(fid, tree):
      """Aux function."""
      #   Find the desired block
      events = dir_tree_find(tree, FIFF.FIFFB_MNE_EVENTS)
  
      if len(events) == 0:
          fid.close()
          raise ValueError("Could not find event data")
  
      events = events[0]
      event_list = None
      event_id = None
      for d in events["directory"]:
          kind = d.kind
          pos = d.pos
          if kind == FIFF.FIFF_MNE_EVENT_LIST:
              tag = read_tag(fid, pos)
              event_list = tag.data
              break
      if event_list is None:
          raise ValueError("Could not find any events")
      else:
          event_list.shape = (-1, 3)
      for d in events["directory"]:
          kind = d.kind
          pos = d.pos
          if kind == FIFF.FIFF_DESCRIPTION:
              tag = read_tag(fid, pos)
              event_id = tag.data
              m_ = [
                  [s[::-1] for s in m[::-1].split(":", 1)]
                  for m in event_id.split(";")
              ]
              event_id = {k: int(v) for v, k in m_}
              break
          elif kind == FIFF.FIFF_MNE_EVENT_COMMENTS:
              tag = read_tag(fid, pos)
              event_id = tag.data
              event_id = (
                  event_id.tobytes()
                  .decode("latin-1")
                  .split("\x00")[:-1]
              )
              assert len(event_id) == len(event_list)
              event_id = {k: v[2] for k, v in zip(event_id, event_list)}
              break
      return event_list, event_id
  
imports: from collections.abc import Sequence
  from pathlib import Path
  import numpy
  from ._fiff.constants import FIFF
  from ._fiff.open import fiff_open
  from ._fiff.pick import pick_channels
  from ._fiff.tag import read_tag
  from ._fiff.tree import dir_tree_find
  from ._fiff.write import end_block, start_and_end_file, start_block, write_int
  from .utils import _check_fname, _check_integer_or_list, _check_on_missing, _check_option, _get_stim_channel, _on_missing, _pl, _validate_type, check_fname, fill_doc, logger, verbose, warn
label_desc: Use image node_id 3 for calling a global function with example usage: _read_events_fif(fid, tree) and returns: event_list,  event_id