code: def make_compensator(info, from_, to, exclude_comp_chs=False):
      """Return compensation matrix eg. for CTF system.
  
      Create a compensation matrix to bring the data from one compensation
      state to another.
  
      Parameters
      ----------
      %(info_not_none)s
      from_ : int
          Compensation in the input data.
      to : int
          Desired compensation in the output.
      exclude_comp_chs : bool
          Exclude compensation channels from the output.
  
      Returns
      -------
      comp : array | None.
          The compensation matrix. Might be None if no compensation
          is needed (from == to).
      """
      if from_ == to:
          return None
  
      #   s_orig = s_from + C1*s_from = (I + C1)*s_from
      #   s_to   = s_orig - C2*s_orig = (I - C2)*s_orig
      #   s_to   = (I - C2)*(I + C1)*s_from = (I + C1 - C2 - C2*C1)*s_from
      if from_ != 0:
          C1 = _make_compensator(info, from_)
          comp_from_0 = np.linalg.inv(np.eye(info["nchan"]) - C1)
      if to != 0:
          C2 = _make_compensator(info, to)
          comp_0_to = np.eye(info["nchan"]) - C2
      if from_ != 0:
          if to != 0:
              # This is mathematically equivalent, but has higher numerical
              # error than using the inverse to always go to zero and back
              # comp = np.eye(info['nchan']) + C1 - C2 - np.dot(C2, C1)
              comp = np.dot(comp_0_to, comp_from_0)
          else:
              comp = comp_from_0
      else:
          # from == 0, to != 0 guaranteed here
          comp = comp_0_to
  
      if exclude_comp_chs:
          pick = [
              k
              for k, c in enumerate(info["chs"])
              if c["kind"] != FIFF.FIFFV_REF_MEG_CH
          ]
  
          if len(pick) == 0:
              raise ValueError(
                  "Nothing remains after excluding the "
                  "compensation channels"
              )
  
          comp = comp[pick, :]
  
      return comp
  
imports: import numpy
  from ..utils import fill_doc
  from .constants import FIFF
label_desc: Use image node_id 4 for calling a global function with example usage: make_compensator(info, from_, to, exclude_comp_chs) and returns: comp, None