code: def _conv_comp(comp, first, last, chs):
      """Add a new converted compensation data item."""
      ch_names = [c["ch_name"] for c in chs]
      n_col = comp[first]["ncoeff"]
      col_names = comp[first]["sensors"][:n_col]
      row_names = [
          comp[p]["sensor_name"] for p in range(first, last + 1)
      ]
      mask = np.isin(col_names, ch_names)  # missing channels excluded
      col_names = np.array(col_names)[mask].tolist()
      n_col = len(col_names)
      n_row = len(row_names)
      ccomp = dict(
          ctfkind=comp[first]["coeff_type"], save_calibrated=False
      )
      _add_kind(ccomp)
  
      data = np.empty((n_row, n_col))
      for ii, coeffs in enumerate(comp[first : last + 1]):
          # Pick the elements to the matrix
          data[ii, :] = coeffs["coeffs"][mask]
      ccomp["data"] = dict(
          row_names=row_names,
          col_names=col_names,
          data=data,
          nrow=len(row_names),
          ncol=len(col_names),
      )
      mk = ("proper_gain", "qgain")
      _calibrate_comp(
          ccomp, chs, row_names, col_names, mult_keys=mk, flip=True
      )
      return ccomp
  
imports: import os.path
  from calendar import timegm
  from time import strptime
  import numpy
  from ..._fiff.constants import FIFF
  from ..._fiff.ctf_comp import _add_kind, _calibrate_comp
  from ..._fiff.meas_info import _empty_info
  from ..._fiff.write import get_new_file_id
  from ...annotations import Annotations
  from ...transforms import _coord_frame_name, apply_trans, combine_transforms, invert_transform
  from ...utils import _clean_names, logger, warn
  from .constants import CTF
label_desc: Use image node_id 9 for calling a global function with example usage: _conv_comp(comp, first, last, chs) and returns: ccomp