code: def _check_chpi_param(chpi_, name):
      if name == "chpi_locs":
          want_ndims = dict(times=1, rrs=3, moments=3, gofs=2)
          extra_keys = list()
      else:
          assert name == "chpi_amplitudes"
          want_ndims = dict(times=1, slopes=3)
          extra_keys = ["proj"]
  
      _validate_type(chpi_, dict, name)
      want_keys = list(want_ndims.keys()) + extra_keys
      if set(want_keys).symmetric_difference(chpi_):
          raise ValueError(
              f"{name} must be a dict with entries {want_keys}, got "
              f"{sorted(chpi_.keys())}"
          )
      n_times = None
      for key, want_ndim in want_ndims.items():
          key_str = f"{name}[{key}]"
          val = chpi_[key]
          _validate_type(val, np.ndarray, key_str)
          shape = val.shape
          if val.ndim != want_ndim:
              raise ValueError(
                  f"{key_str} must have ndim={want_ndim}, got {val.ndim}"
              )
          if n_times is None and key != "proj":
              n_times = shape[0]
          if n_times != shape[0] and key != "proj":
              raise ValueError(
                  f"{name} have inconsistent number of time points in {want_keys}"
              )
      if name == "chpi_locs":
          n_coils = chpi_["rrs"].shape[1]
          for key in ("gofs", "moments"):
              val = chpi_[key]
              if val.shape[1] != n_coils:
                  raise ValueError(
                      f'chpi_locs["rrs"] had values for {n_coils} coils but '
                      f'chpi_locs["{key}"] had values for {val.shape[1]} coils'
                  )
          for key in ("rrs", "moments"):
              val = chpi_[key]
              if val.shape[2] != 3:
                  raise ValueError(
                      f'chpi_locs["{key}"].shape[2] must be 3, got shape {shape}'
                  )
      else:
          assert name == "chpi_amplitudes"
          slopes, proj = chpi_["slopes"], chpi_["proj"]
          _validate_type(proj, Projection, 'chpi_amplitudes["proj"]')
          n_ch = len(proj["data"]["col_names"])
          if slopes.shape[0] != n_times or slopes.shape[2] != n_ch:
              raise ValueError(
                  f"slopes must have shape[0]=={n_times} and shape[2]=={n_ch}, got shape "
                  f"{slopes.shape}"
              )
  
imports: import copy
  import itertools
  from functools import partial
  import numpy
  from scipy.linalg import orth
  from scipy.optimize import fmin_cobyla
  from scipy.spatial.distance import cdist
  from ._fiff.constants import FIFF
  from ._fiff.meas_info import Info, _simplify_info
  from ._fiff.pick import _picks_to_idx, pick_channels, pick_channels_regexp, pick_info, pick_types
  from ._fiff.proj import Projection, setup_proj
  from .channels.channels import _get_meg_system
  from .cov import compute_whitener, make_ad_hoc_cov
  from .dipole import _make_guesses
  from .event import find_events
  from .fixes import jit
  from .forward import _concatenate_coils, _create_meg_coils, _magnetic_dipole_field_vec
  from .io import BaseRaw
  from .io.ctf.trans import _make_ctf_coord_trans_set
  from .io.kit.constants import KIT
  from .io.kit.kit import RawKIT
  from .preprocessing.maxwell import _get_mf_picks_fix_mags, _prep_mf_coils, _regularize_out, _sss_basis
  from .transforms import _angle_between_quats, _fit_matched_points, _quat_to_affine, als_ras_trans, apply_trans, invert_transform, quat_to_rot, rot_to_quat
  from .utils import ProgressBar, _check_fname, _check_option, _on_missing, _pl, _validate_type, _verbose_safe_false, logger, use_log_level, verbose, warn
label_desc: Use image node_id 23 for calling a global function with example usage: _check_chpi_param(chpi_, name) without return types