code: def _get_label_power(power, labels, vertno, k_idxs):
      """Average power across vertices in labels."""
      (_, ps1, ps2) = power.shape
      # construct out array with correct shape
      out_power = np.zeros(shape=(len(labels), ps1, ps2))
  
      # for each label, compile list of vertices we want
      for li in np.arange(len(labels)):
          lab = labels[li]
          hemis = ("lh", "rh")
          all_vnums = [[], []]
          if lab.hemi == "both":
              all_vnums[0] = np.intersect1d(lab.lh.vertices, vertno[0])
              all_vnums[1] = np.intersect1d(lab.rh.vertices, vertno[1])
          else:
              assert lab.hemi == "lh" or lab.hemi == "rh"
              h_id = 0 if lab.hemi == "lh" else 1
              all_vnums[h_id] = np.intersect1d(
                  vertno[h_id], lab.vertices
              )
  
          verts = [
              (hemis[hi], vn) for hi in range(2) for vn in all_vnums[hi]
          ]
  
          # restrict power to relevant vertices in label
          lab_mask = np.array([False] * len(power))
          for vert in verts:
              lab_mask[
                  k_idxs[vert]
              ] = True  # k_idxs[vert] gives power row index
          lab_power = power[lab_mask]  # only pass through rows we want
          assert lab_power.shape == (len(verts), ps1, ps2)
  
          # set correct out values for label
          out_power[li, :, :] = np.mean(lab_power, axis=0)
  
      assert out_power.shape == (len(labels), ps1, ps2)
      return out_power
  
imports: import numpy
  from .._fiff.constants import FIFF
  from .._fiff.pick import pick_info
  from ..baseline import _log_rescale, rescale
  from ..epochs import Epochs
  from ..event import make_fixed_length_events
  from ..evoked import EvokedArray
  from ..fixes import _safe_svd
  from ..label import BiHemiLabel, Label
  from ..parallel import parallel_func
  from ..source_estimate import _make_stc
  from ..time_frequency.multitaper import _compute_mt_params, _mt_spectra, _psd_from_mt, _psd_from_mt_adaptive
  from ..time_frequency.tfr import cwt, morlet
  from ..utils import ProgressBar, _check_option, _pl, _validate_type, logger, verbose
  from .inverse import INVERSE_METHODS, _assemble_kernel, _check_or_prepare, _check_ori, _pick_channels_inverse_operator, _subject_from_inverse, combine_xyz
label_desc: Use image node_id 7 for calling a global function with example usage: _get_label_power(power, labels, vertno, k_idxs) and returns: out_power