code: def _configure_grid(axes, grid, tri, size):
      """Help for plot_matrix."""
      # Different grids for different layouts
      if tri == "lower":
          for i in range(size):
              # Correct for weird mis-sizing
              i = 1.001 * i
              axes.plot(
                  [i + 0.5, i + 0.5],
                  [size - 0.5, i + 0.5],
                  color="grey",
              )
              axes.plot(
                  [i + 0.5, -0.5], [i + 0.5, i + 0.5], color="grey"
              )
      elif tri == "diag":
          for i in range(size):
              # Correct for weird mis-sizing
              i = 1.001 * i
              axes.plot(
                  [i + 0.5, i + 0.5],
                  [size - 0.5, i - 0.5],
                  color="grey",
              )
              axes.plot(
                  [i + 0.5, -0.5], [i - 0.5, i - 0.5], color="grey"
              )
      else:
          for i in range(size):
              # Correct for weird mis-sizing
              i = 1.001 * i
              axes.plot(
                  [i + 0.5, i + 0.5], [size - 0.5, -0.5], color="grey"
              )
              axes.plot(
                  [size - 0.5, -0.5], [i + 0.5, i + 0.5], color="grey"
              )
  
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 10 for calling a global function with example usage: _configure_grid(axes, grid, tri, size) without return types