code: def _mask_matrix(mat, tri):
      """Help for plot_matrix.
  
      This function masks the matrix depending on the provided
      value of ``tri``.
      """
      if tri == "lower":
          mask = np.tri(mat.shape[0], k=-1, dtype=bool) ^ True
      else:
          mask = np.tri(mat.shape[0], dtype=bool) ^ True
      return np.ma.masked_array(mat, mask)
  
imports: import warnings
  import matplotlib.patches
  import matplotlib.pyplot
  import numpy
  import pandas
  from mpl_toolkits.axes_grid1 import make_axes_locatable
  from scipy.cluster.hierarchy import leaves_list, linkage, optimal_leaf_ordering
  from nilearn.glm.first_level.experimental_paradigm import check_events
  from .._utils import fill_doc
label_desc: Use image node_id 8 for calling a global function with example usage: _mask_matrix(mat, tri) and returns: np