code: def unify_bad_channels(insts):
      """Unify bad channels across a list of instances.
  
      All instances must be of the same type and have matching channel names and channel
      order. The ``.info["bads"]`` of each instance will be set to the union of
      ``.info["bads"]`` across all instances.
  
      Parameters
      ----------
      insts : list
          List of instances (:class:`~mne.io.Raw`, :class:`~mne.Epochs`,
          :class:`~mne.Evoked`, :class:`~mne.time_frequency.Spectrum`,
          :class:`~mne.time_frequency.EpochsSpectrum`) across which to unify bad channels.
  
      Returns
      -------
      insts : list
          List of instances with bad channels unified across instances.
  
      See Also
      --------
      mne.channels.equalize_channels
      mne.channels.rename_channels
      mne.channels.combine_channels
  
      Notes
      -----
      This function modifies the instances in-place.
  
      .. versionadded:: 1.6
      """
      from ..epochs import Epochs
      from ..evoked import Evoked
      from ..io import BaseRaw
      from ..time_frequency.spectrum import BaseSpectrum
  
      # ensure input is list-like
      _validate_type(insts, (list, tuple), "insts")
      # ensure non-empty
      if len(insts) == 0:
          raise ValueError("insts must not be empty")
      # ensure all insts are MNE objects, and all the same type
      inst_type = type(insts[0])
      valid_types = (BaseRaw, Epochs, Evoked, BaseSpectrum)
      for inst in insts:
          _validate_type(inst, valid_types, "each object in insts")
          if type(inst) != inst_type:
              raise ValueError("All insts must be the same type")
  
      # ensure all insts have the same channels and channel order
      ch_names = insts[0].ch_names
      for inst in insts[1:]:
          dif = set(inst.ch_names) ^ set(ch_names)
          if len(dif):
              raise ValueError(
                  "Channels do not match across the objects in insts. Consider calling "
                  "equalize_channels before calling this function."
              )
          elif inst.ch_names != ch_names:
              raise ValueError(
                  "Channel names are sorted differently across instances. Please use "
                  "mne.channels.equalize_channels."
              )
  
      # collect bads as dict keys so that insertion order is preserved, then cast to list
      all_bads = dict()
      for inst in insts:
          all_bads.update(dict.fromkeys(inst.info["bads"]))
      all_bads = list(all_bads)
  
      # update bads on all instances
      for inst in insts:
          inst.info["bads"] = all_bads
  
      return insts
  
imports: import os.path
  import string
  import sys
  from collections import OrderedDict
  from copy import deepcopy
  from dataclasses import dataclass
  from functools import partial
  from pathlib import Path
  from typing import Union
  import numpy
  from scipy.io import loadmat
  from scipy.sparse import csr_matrix, lil_matrix
  from scipy.spatial import Delaunay
  from scipy.stats import zscore
  from .._fiff.constants import FIFF
  from .._fiff.meas_info import Info, MontageMixin, _merge_info, _rename_comps, _unit2human, create_info
  from .._fiff.pick import _check_excludes_includes, _pick_data_channels, _picks_by_type, _picks_to_idx, _second_rules, channel_indices_by_type, channel_type, pick_channels, pick_info, pick_types
  from .._fiff.proj import setup_proj
  from .._fiff.reference import add_reference_channels, set_eeg_reference
  from .._fiff.tag import _rename_list
  from ..bem import _check_origin
  from ..defaults import HEAD_SIZE_DEFAULT, _handle_default
  from ..utils import _check_dict_keys, _check_fname, _check_option, _check_preload, _get_stim_channel, _on_missing, _validate_type, fill_doc, legacy, logger, verbose, warn
label_desc: Use image node_id 3 for calling a global function with example usage: unify_bad_channels(insts) and returns: insts