code: def _rotate_coil(new_z, old_z, all_coils, idx, inplace=False):
      """Adjust coils."""
      # Turn NX and NY to the plane determined by NZ
      old_z = old_z / np.linalg.norm(old_z)
      new_z = new_z / np.linalg.norm(new_z)
      rot = _find_vector_rotation(
          old_z, new_z
      )  # additional coil rotation
      this_sl = all_coils[5][idx]
      this_rmag = np.dot(rot, all_coils[0][this_sl].T).T
      this_cosmag = np.dot(rot, all_coils[1][this_sl].T).T
      if inplace:
          all_coils[0][this_sl] = this_rmag
          all_coils[1][this_sl] = this_cosmag
      subset = (
          this_rmag,
          this_cosmag,
          np.zeros(this_rmag.shape[0], int),
          1,
          all_coils[4][[idx]],
          {0: this_sl},
      )
      return subset
  
imports: from collections import defaultdict
  from functools import partial
  import numpy
  from scipy.optimize import fmin_cobyla
  from .._fiff.pick import pick_info, pick_types
  from .._fiff.tag import _coil_trans_to_loc, _loc_to_coil_trans
  from ..bem import _check_origin
  from ..io import BaseRaw
  from ..transforms import _find_vector_rotation
  from ..utils import _check_fname, _check_option, _ensure_int, _pl, _reg_pinv, _validate_type, check_fname, logger, verbose
  from .maxwell import _col_norm_pinv, _get_grad_point_coilsets, _prep_fine_cal, _prep_mf_coils, _read_cross_talk, _trans_sss_basis
label_desc: Use image node_id 7 for calling a global function with example usage: _rotate_coil(new_z, old_z, all_coils, idx, inplace) and returns: subset