code: def solver(M, G, n_orient):
      """Run L2 penalized regression and keep 10 strongest locations.
  
      Parameters
      ----------
      M : array, shape (n_channels, n_times)
          The whitened data.
      G : array, shape (n_channels, n_dipoles)
          The gain matrix a.k.a. the forward operator. The number of locations
          is n_dipoles / n_orient. n_orient will be 1 for a fixed orientation
          constraint or 3 when using a free orientation model.
      n_orient : int
          Can be 1 or 3 depending if one works with fixed or free orientations.
          If n_orient is 3, then ``G[:, 2::3]`` corresponds to the dipoles that
          are normal to the cortex.
  
      Returns
      -------
      X : array, (n_active_dipoles, n_times)
          The time series of the dipoles in the active set.
      active_set : array (n_dipoles)
          Array of bool. Entry j is True if dipole j is in the active set.
          We have ``X_full[active_set] == X`` where X_full is the full X matrix
          such that ``M = G X_full``.
      """
      inner = np.dot(G, G.T)
      trace = np.trace(inner)
      K = linalg.solve(inner + 4e-6 * trace * np.eye(G.shape[0]), G).T
      K /= np.linalg.norm(K, axis=1)[:, None]
      X = np.dot(K, M)
  
      indices = np.argsort(np.sum(X**2, axis=1))[-10:]
      active_set = np.zeros(G.shape[1], dtype=bool)
      for idx in indices:
          idx -= idx % n_orient
          active_set[idx : idx + n_orient] = True
      X = X[active_set]
      return X, active_set
  
imports: import numpy
  from scipy import linalg
  import mne
  from mne.datasets import sample
  from mne.viz import plot_sparse_source_estimates
label_desc: Use image node_id 2 for calling a global function with example usage: solver(M, G, n_orient) and returns: X,  active_set