code: def _interpolate_bads_seeg(
      inst, exclude=None, tol=2e-3, verbose=None
  ):
      if exclude is None:
          exclude = list()
      picks = pick_types(
          inst.info, meg=False, seeg=True, exclude=exclude
      )
      inst.info._check_consistency()
      bads_idx = np.isin(
          np.array(inst.ch_names)[picks], inst.info["bads"]
      )
  
      if len(picks) == 0 or bads_idx.sum() == 0:
          return
  
      pos = inst._get_channel_positions(picks)
  
      # Make sure only sEEG are used
      bads_idx_pos = bads_idx[picks]
  
      shafts = _find_seeg_electrode_shaft(pos, tol=tol)
  
      # interpolate the bad contacts
      picks_bad = list(np.where(bads_idx_pos)[0])
      for shaft in shafts:
          bads_shaft = np.array(
              [idx for idx in picks_bad if idx in shaft]
          )
          if bads_shaft.size == 0:
              continue
          goods_shaft = shaft[np.isin(shaft, bads_shaft, invert=True)]
          if goods_shaft.size < 2:
              raise RuntimeError(
                  f"{goods_shaft.size} good contact(s) found in a line "
                  f" with {np.array(inst.ch_names)[bads_shaft]}, "
                  "at least 2 are required for interpolation. "
                  "Dropping this channel/these channels is recommended."
              )
          logger.debug(
              f"Interpolating {np.array(inst.ch_names)[bads_shaft]} using "
              f"data from {np.array(inst.ch_names)[goods_shaft]}"
          )
          bads_shaft_idx = np.where(np.isin(shaft, bads_shaft))[0]
          goods_shaft_idx = np.where(~np.isin(shaft, bads_shaft))[0]
          n1, n2 = pos[shaft][:2]
          ts = np.array(
              [
                  -np.dot(n1 - n0, n2 - n1)
                  / np.linalg.norm(n2 - n1) ** 2
                  for n0 in pos[shaft]
              ]
          )
          if np.any(np.diff(ts) < 0):
              ts *= -1
          y = np.arange(inst._data.shape[-1])
          inst._data[bads_shaft] = RectBivariateSpline(
              x=ts[goods_shaft_idx], y=y, z=inst._data[goods_shaft]
          )(x=ts[bads_shaft_idx], y=y)
  
imports: import numpy
  from numpy.polynomial.legendre import legval
  from scipy.interpolate import RectBivariateSpline
  from scipy.linalg import pinv
  from scipy.spatial.distance import pdist, squareform
  from .._fiff.meas_info import _simplify_info
  from .._fiff.pick import pick_channels, pick_info, pick_types
  from ..surface import _normalize_vectors
  from ..utils import _validate_type, logger, verbose, warn
label_desc: Use image node_id 12 for calling a global function with example usage: _interpolate_bads_seeg(inst, exclude, tol, verbose) without return types