def METHOD_NAME(fid, kind, mat):
    """Write named matrix from the given node.
    Parameters
    ----------
    fid : file
        The opened file descriptor.
    kind : int
        The kind of the matrix.
    matkind : int
        The type of matrix.
    """
    # let's save ourselves from disaster
    n_tot = mat["nrow"] * mat["ncol"]
    if mat["data"].size != n_tot:
        ratio = n_tot / float(mat["data"].size)
        if n_tot < mat["data"].size and ratio > 0:
            ratio = 1 / ratio
        raise ValueError(
            "Cannot write matrix: row (%i) and column (%i) "
            "total element (%i) mismatch with data size (%i), "
            "appears to be off by a factor of %gx"
            % (mat["nrow"], mat["ncol"], n_tot, mat["data"].size, ratio)
        )
    start_block(fid, FIFF.FIFFB_MNE_NAMED_MATRIX)
    write_int(fid, FIFF.FIFF_MNE_NROW, mat["nrow"])
    write_int(fid, FIFF.FIFF_MNE_NCOL, mat["ncol"])
    if len(mat["row_names"]) > 0:
        # let's prevent unintentional stupidity
        if len(mat["row_names"]) != mat["nrow"]:
            raise ValueError('len(mat["row_names"]) != mat["nrow"]')
        write_name_list(fid, FIFF.FIFF_MNE_ROW_NAMES, mat["row_names"])
    if len(mat["col_names"]) > 0:
        # let's prevent unintentional stupidity
        if len(mat["col_names"]) != mat["ncol"]:
            raise ValueError('len(mat["col_names"]) != mat["ncol"]')
        write_name_list(fid, FIFF.FIFF_MNE_COL_NAMES, mat["col_names"])
    write_float_matrix(fid, kind, mat["data"])
    end_block(fid, FIFF.FIFFB_MNE_NAMED_MATRIX)