code: def _read_named_matrix(
      fid, node, matkind, indent="    ", transpose=False
  ):
      """Read named matrix from the given node.
  
      Parameters
      ----------
      fid : file
          The opened file descriptor.
      node : dict
          The node in the tree.
      matkind : int
          The type of matrix.
      transpose : bool
          If True, transpose the matrix. Default is False.
      %(verbose)s
  
      Returns
      -------
      mat: dict
          The matrix data
      """
      #   Descend one level if necessary
      if node["block"] != FIFF.FIFFB_MNE_NAMED_MATRIX:
          for k in range(node["nchild"]):
              if (
                  node["children"][k]["block"]
                  == FIFF.FIFFB_MNE_NAMED_MATRIX
              ):
                  if has_tag(node["children"][k], matkind):
                      node = node["children"][k]
                      break
          else:
              logger.info(
                  indent + "Desired named matrix (kind = %d) not "
                  "available" % matkind
              )
              return None
      else:
          if not has_tag(node, matkind):
              logger.info(
                  indent + "Desired named matrix (kind = %d) not "
                  "available" % matkind
              )
              return None
  
      #   Read everything we need
      tag = find_tag(fid, node, matkind)
      if tag is None:
          raise ValueError("Matrix data missing")
      else:
          data = tag.data
  
      nrow, ncol = data.shape
      tag = find_tag(fid, node, FIFF.FIFF_MNE_NROW)
      if tag is not None and tag.data != nrow:
          raise ValueError(
              "Number of rows in matrix data and FIFF_MNE_NROW "
              "tag do not match"
          )
  
      tag = find_tag(fid, node, FIFF.FIFF_MNE_NCOL)
      if tag is not None and tag.data != ncol:
          raise ValueError(
              "Number of columns in matrix data and "
              "FIFF_MNE_NCOL tag do not match"
          )
  
      tag = find_tag(fid, node, FIFF.FIFF_MNE_ROW_NAMES)
      row_names = tag.data.split(":") if tag is not None else []
  
      tag = find_tag(fid, node, FIFF.FIFF_MNE_COL_NAMES)
      col_names = tag.data.split(":") if tag is not None else []
  
      mat = dict(
          nrow=nrow,
          ncol=ncol,
          row_names=row_names,
          col_names=col_names,
          data=data,
      )
      if transpose:
          _transpose_named_matrix(mat)
      return mat
  
imports: from ..utils import logger
  from .constants import FIFF
  from .tag import find_tag, has_tag
  from .write import end_block, start_block, write_float_matrix, write_int, write_name_list
label_desc: Use image node_id 2 for calling a global function with example usage: _read_named_matrix(fid, node, matkind, indent, transpose) and returns: mat, None, None