code: def test_equalize_bads(interp_thresh, inst_type):
      """Test equalize_bads function."""
      raw, epochs, evoked = _load_data()
  
      if inst_type == "raw":
          insts = [raw.copy().crop(0, 1), raw.copy().crop(0, 2)]
      elif inst_type == "epochs":
          insts = [epochs.copy()[:1], epochs.copy()[:2]]
      else:
          insts = [evoked.copy().crop(0, 0.1), raw.copy().crop(0, 0.2)]
  
      with pytest.raises(ValueError, match="between 0"):
          equalize_bads(insts, interp_thresh=2.0)
  
      bads = insts[0].copy().pick("eeg").ch_names[:3]
      insts[0].info["bads"] = bads[:2]
      insts[1].info["bads"] = bads[1:]
  
      insts_ok = equalize_bads(insts, interp_thresh=interp_thresh)
      if interp_thresh == 0:
          bads_ok = []
      elif interp_thresh == 1:
          bads_ok = bads
      else:  # interp_thresh == 0.5
          bads_ok = bads[1:]
  
      for inst in insts_ok:
          assert set(inst.info["bads"]) == set(bads_ok)
  
file_path: mne-python/mne/preprocessing/tests/test_interpolate.py
imports: import itertools
  from pathlib import Path
  import numpy
  import pytest
  from mne import Epochs, create_info, io, pick_types, read_events
  from mne.channels import make_standard_montage
  from mne.preprocessing import equalize_bads, interpolate_bridged_electrodes
  from mne.preprocessing.interpolate import _find_centroid_sphere
  from mne.transforms import _cart_to_sph
label_desc: Use image node_id 2 for calling a global function with example usage: test_equalize_bads(interp_thresh, inst_type) without return types