code: def _check_compensation_grade(
      info1, info2, name1, name2="data", ch_names=None
  ):
      """Ensure that objects have same compensation_grade."""
      from .._fiff.compensator import get_current_comp
      from .._fiff.meas_info import Info
      from .._fiff.pick import pick_channels, pick_info
  
      for t_info in (info1, info2):
          if t_info is None:
              return
          assert isinstance(
              t_info, Info
          ), t_info  # or internal code is wrong
  
      if ch_names is not None:
          info1 = info1.copy()
          info2 = info2.copy()
          # pick channels
          for t_info in [info1, info2]:
              if t_info["comps"]:
                  with t_info._unlock():
                      t_info["comps"] = []
              picks = pick_channels(
                  t_info["ch_names"], ch_names, ordered=False
              )
              pick_info(t_info, picks, copy=False)
      # "or 0" here aliases None -> 0, as they are equivalent
      grade1 = get_current_comp(info1) or 0
      grade2 = get_current_comp(info2) or 0
  
      # perform check
      if grade1 != grade2:
          raise RuntimeError(
              "Compensation grade of %s (%s) and %s (%s) do not match"
              % (name1, grade1, name2, grade2)
          )
  
imports: import numbers
  import operator
  import os
  import re
  from builtins import input
  from difflib import get_close_matches
  from importlib import import_module
  from pathlib import Path
  import numpy
  from ..defaults import HEAD_SIZE_DEFAULT, _handle_default
  from ..fixes import _compare_version, _median_complex
  from ._logging import _record_warnings, _verbose_safe_false, logger, verbose, warn
label_desc: Use image node_id 15 for calling a global function with example usage: _check_compensation_grade(info1, info2, name1, name2, ch_names) without return types