code: def _find_stim_steps(
      data, first_samp, pad_start=None, pad_stop=None, merge=0
  ):
      changed = np.diff(data, axis=1) != 0
      idx = np.where(np.all(changed, axis=0))[0]
      if len(idx) == 0:
          return np.empty((0, 3), dtype="int32")
  
      pre_step = data[0, idx]
      idx += 1
      post_step = data[0, idx]
      idx += first_samp
      steps = np.c_[idx, pre_step, post_step]
  
      if pad_start is not None:
          v = steps[0, 1]
          if v != pad_start:
              steps = np.insert(steps, 0, [0, pad_start, v], axis=0)
  
      if pad_stop is not None:
          v = steps[-1, 2]
          if v != pad_stop:
              last_idx = len(data[0]) + first_samp
              steps = np.append(
                  steps, [[last_idx, v, pad_stop]], axis=0
              )
  
      if merge != 0:
          diff = np.diff(steps[:, 0])
          idx = diff <= abs(merge)
          if np.any(idx):
              where = np.where(idx)[0]
              keep = np.logical_not(idx)
              if merge > 0:
                  # drop the earlier event
                  steps[where + 1, 1] = steps[where, 1]
                  keep = np.append(keep, True)
              else:
                  # drop the later event
                  steps[where, 2] = steps[where + 1, 2]
                  keep = np.insert(keep, 0, True)
  
              is_step = steps[:, 1] != steps[:, 2]
              keep = np.logical_and(keep, is_step)
              steps = steps[keep]
  
      return steps
  
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 6 for calling a global function with example usage: _find_stim_steps(data, first_samp, pad_start, pad_stop, merge) and returns: steps, np