code: def _get_idx_label_stc(label, stc):
      hemi_idx_mapping = dict(lh=0, rh=1)
  
      hemi_idx = hemi_idx_mapping[label.hemi]
  
      idx = np.intersect1d(stc.vertices[hemi_idx], label.vertices)
      idx = np.searchsorted(stc.vertices[hemi_idx], idx)
  
      if hemi_idx == 1:
          idx += len(stc.vertices[0])
      return idx
  
file_path: mne-python/mne/simulation/tests/test_source.py
imports: import numpy
  import pytest
  from numpy.testing import assert_array_almost_equal, assert_array_equal, assert_equal
  from mne import convert_forward_solution, pick_types_forward, read_forward_solution, read_label
  from mne.datasets import testing
  from mne.label import Label
  from mne.simulation import SourceSimulator, simulate_sparse_stc, simulate_stc
label_desc: Use image node_id 2 for calling a global function with example usage: _get_idx_label_stc(label, stc) and returns: idx