code: def _ensure_events(events):
      err_msg = f"events should be a NumPy array of integers, got {type(events)}"
      with _record_warnings():
          try:
              events = np.asarray(events)
          except ValueError as np_err:
              if str(np_err).startswith(
                  "setting an array element with a sequence. The requested "
                  "array has an inhomogeneous shape"
              ):
                  raise TypeError(err_msg) from None
              else:
                  raise
      if not np.issubdtype(events.dtype, np.integer):
          raise TypeError(err_msg)
      if events.ndim != 2 or events.shape[1] != 3:
          raise ValueError(
              f"events must be of shape (N, 3), got {events.shape}"
          )
      return events
  
imports: import numbers
  import operator
  import os
  import re
  from builtins import input
  from difflib import get_close_matches
  from importlib import import_module
  from pathlib import Path
  import numpy
  from ..defaults import HEAD_SIZE_DEFAULT, _handle_default
  from ..fixes import _compare_version, _median_complex
  from ._logging import _record_warnings, _verbose_safe_false, logger, verbose, warn
label_desc: Use image node_id 50 for calling a global function with example usage: _ensure_events(events) and returns: events