code: def compute_native_head_t(
      montage, *, on_missing="warn", verbose=None
  ):
      """Compute the native-to-head transformation for a montage.
  
      This uses the fiducials in the native space to transform to compute the
      transform to the head coordinate frame.
  
      Parameters
      ----------
      montage : instance of DigMontage
          The montage.
      %(on_missing_fiducials)s
  
          .. versionadded:: 1.2
      %(verbose)s
  
      Returns
      -------
      native_head_t : instance of Transform
          A native-to-head transformation matrix.
      """
      # Get fiducial points and their coord_frame
      fid_coords, coord_frame = _get_fid_coords(
          montage.dig, raise_error=False
      )
      if coord_frame is None:
          coord_frame = FIFF.FIFFV_COORD_UNKNOWN
      if coord_frame == FIFF.FIFFV_COORD_HEAD:
          native_head_t = np.eye(4)
      else:
          fid_keys = ("nasion", "lpa", "rpa")
          for key in fid_keys:
              this_coord = fid_coords[key]
              if this_coord is None or np.any(np.isnan(this_coord)):
                  msg = (
                      f"Fiducial point {key} not found, assuming identity "
                      f"{_verbose_frames[coord_frame]} to head transformation"
                  )
                  _on_missing(on_missing, msg, error_klass=RuntimeError)
                  native_head_t = np.eye(4)
                  break
          else:
              native_head_t = get_ras_to_neuromag_trans(
                  *[fid_coords[key] for key in fid_keys]
              )
      return Transform(coord_frame, "head", native_head_t)
  
imports: import os.path
  import re
  from collections import OrderedDict
  from copy import deepcopy
  from dataclasses import dataclass
  import numpy
  from .._fiff._digitization import _coord_frame_const, _count_points_by_type, _ensure_fiducials_head, _format_dig_points, _get_data_as_dict_from_dig, _get_dig_eeg, _get_fid_coords, _make_dig_points, _read_dig_fif, write_dig
  from .._fiff.constants import CHANNEL_LOC_ALIASES, FIFF
  from .._fiff.meas_info import create_info
  from .._fiff.open import fiff_open
  from .._fiff.pick import _picks_to_idx, channel_type, pick_types
  from .._freesurfer import get_mni_fiducials
  from ..defaults import HEAD_SIZE_DEFAULT
  from ..transforms import Transform, _ensure_trans, _fit_matched_points, _frame_to_str, _quat_to_affine, _sph_to_cart, _topo_to_sph, _verbose_frames, apply_trans, get_ras_to_neuromag_trans
  from ..utils import _check_fname, _check_option, _on_missing, _pl, _validate_type, copy_function_doc_to_method_doc, fill_doc, verbose, warn
  from ..utils.docs import docdict
  from ..viz import plot_montage
  from ._dig_montage_utils import _parse_brainvision_dig_montage, _read_dig_montage_egi
label_desc: Use image node_id 23 for calling a global function with example usage: compute_native_head_t(montage) and returns: Transform