code: def _write_matrix_data(fid, kind, mat, data_type):
      dtype = {
          FIFF.FIFFT_FLOAT: ">f4",
          FIFF.FIFFT_DOUBLE: ">f8",
          FIFF.FIFFT_COMPLEX_FLOAT: ">c8",
          FIFF.FIFFT_COMPLEX_DOUBLE: ">c16",
          FIFF.FIFFT_INT: ">i4",
      }[data_type]
      dtype = np.dtype(dtype)
      data_size = dtype.itemsize * mat.size + 4 * (mat.ndim + 1)
      matrix_type = data_type | FIFF.FIFFT_MATRIX
      fid.write(np.array(kind, dtype=">i4").tobytes())
      fid.write(np.array(matrix_type, dtype=">i4").tobytes())
      fid.write(np.array(data_size, dtype=">i4").tobytes())
      fid.write(np.array(FIFF.FIFFV_NEXT_SEQ, dtype=">i4").tobytes())
      fid.write(np.array(mat, dtype=dtype).tobytes())
      dims = np.empty(mat.ndim + 1, dtype=np.int32)
      dims[: mat.ndim] = mat.shape[::-1]
      dims[-1] = mat.ndim
      fid.write(np.array(dims, dtype=">i4").tobytes())
      check_fiff_length(fid)
  
imports: import os.path
  import re
  import time
  import uuid
  from contextlib import contextmanager
  from gzip import GzipFile
  import numpy
  from scipy.sparse import csc_matrix, csr_matrix
  from ..utils import _file_like, _validate_type, logger
  from ..utils.numerics import _cal_to_julian
  from .constants import FIFF
label_desc: Use image node_id 20 for calling a global function with example usage: _write_matrix_data(fid, kind, mat, data_type) without return types