code: def _least_square_evoked(epochs_data, events, tmin, sfreq):
      """Least square estimation of evoked response from epochs data.
  
      Parameters
      ----------
      epochs_data : array, shape (n_channels, n_times)
          The epochs data to estimate evoked.
      events : array, shape (n_events, 3)
          The events typically returned by the read_events function.
          If some events don't match the events of interest as specified
          by event_id, they will be ignored.
      tmin : float
          Start time before event.
      sfreq : float
          Sampling frequency.
  
      Returns
      -------
      evokeds : array, shape (n_class, n_components, n_times)
          An concatenated array of evoked data for each event type.
      toeplitz : array, shape (n_class * n_components, n_channels)
          An concatenated array of toeplitz matrix for each event type.
      """
      n_epochs, n_channels, n_times = epochs_data.shape
      tmax = tmin + n_times / float(sfreq)
  
      # Deal with shuffled epochs
      events = events.copy()
      events[:, 0] -= events[0, 0] + int(tmin * sfreq)
  
      # Construct raw signal
      raw = _construct_signal_from_epochs(
          epochs_data, events, sfreq, tmin
      )
  
      # Compute the independent evoked responses per condition, while correcting
      # for event overlaps.
      n_min, n_max = int(tmin * sfreq), int(tmax * sfreq)
      window = n_max - n_min
      n_samples = raw.shape[1]
      toeplitz = list()
      classes = np.unique(events[:, 2])
      for ii, this_class in enumerate(classes):
          # select events by type
          sel = events[:, 2] == this_class
  
          # build toeplitz matrix
          trig = np.zeros((n_samples, 1))
          ix_trig = (events[sel, 0]) + n_min
          trig[ix_trig] = 1
          toeplitz.append(linalg.toeplitz(trig[0:window], trig))
  
      # Concatenate toeplitz
      toeplitz = np.array(toeplitz)
      X = np.concatenate(toeplitz)
  
      # least square estimation
      predictor = np.dot(linalg.pinv(np.dot(X, X.T)), X)
      evokeds = np.dot(predictor, raw.T)
      evokeds = np.transpose(
          np.vsplit(evokeds, len(classes)), (0, 2, 1)
      )
      return evokeds, toeplitz
  
imports: import numpy
  from scipy import linalg
  from .._fiff.pick import _pick_data_channels, pick_info
  from ..cov import Covariance, _regularized_covariance
  from ..decoding import BaseEstimator, TransformerMixin
  from ..epochs import BaseEpochs
  from ..evoked import Evoked, EvokedArray
  from ..io import BaseRaw
  from ..utils import _check_option, logger
label_desc: Use image node_id 2 for calling a global function with example usage: _least_square_evoked(epochs_data, events, tmin, sfreq) and returns: evokeds,  toeplitz