code: def _interpolate_bads_nan(
      inst,
      ch_type,
      ref_meg=False,
      exclude=(),
      *,
      verbose=None,
  ):
      info = _simplify_info(inst.info)
      picks_type = pick_types(
          info, ref_meg=ref_meg, exclude=exclude, **{ch_type: True}
      )
      use_ch_names = [inst.info["ch_names"][p] for p in picks_type]
      bads_type = [ch for ch in inst.info["bads"] if ch in use_ch_names]
      if len(bads_type) == 0 or len(picks_type) == 0:
          return
      # select the bad channels to be interpolated
      picks_bad = pick_channels(
          inst.info["ch_names"], bads_type, exclude=[]
      )
      inst._data[..., picks_bad, :] = np.nan
  
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 8 for calling a global function with example usage: _interpolate_bads_nan(inst, ch_type, ref_meg, exclude) without return types