code: def _synthesize_stim_channel(events, n_samples):
      """Synthesize a stim channel from events read from an event file.
  
      Parameters
      ----------
      events : array, shape (n_events, 3)
          Each row representing an event.
      n_samples : int
          The number of samples.
  
      Returns
      -------
      stim_channel : array, shape (n_samples,)
          An array containing the whole recording's event marking.
      """
      # select events overlapping buffer
      events = events.copy()
      events[events[:, 1] < 1, 1] = 1
      # create output buffer
      stim_channel = np.zeros(n_samples, int)
      for onset, duration, trigger in events:
          stim_channel[onset : onset + duration] = trigger
      return stim_channel
  
file_path: mne-python/mne/_fiff/utils.py
imports: import os
  import os.path
  import numpy
  from .constants import FIFF
  from .meas_info import _get_valid_units
label_desc: Use image node_id 9 for calling a global function with example usage: _synthesize_stim_channel(events, n_samples) and returns: stim_channel