code: def _sanitize_inputs_plot_matrix(
      mat_shape, tri, labels, reorder, figure, axes
  ):
      """Help for plot_matrix.
  
      This function makes sure the inputs to plot_matrix are valid.
      """
      _sanitize_tri(tri)
      labels = _sanitize_labels(mat_shape, labels)
      reorder = _sanitize_reorder(reorder)
      fig, axes, own_fig = _sanitize_figure_and_axes(figure, axes)
      return labels, reorder, fig, axes, own_fig
  
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 2 for calling a global function with example usage: _sanitize_inputs_plot_matrix(mat_shape, tri, labels, reorder, figure, axes) and returns: labels,  reorder,  fig,  axes,  own_fig