code: def normalize_matrix_on_axis(m, axis=0):
      """Normalize a 2D matrix on an axis.
  
      Parameters
      ----------
      m : numpy 2D array,
          The matrix to normalize.
  
      axis : integer in {0, 1}, default=0
          A valid axis to normalize across.
  
      Returns
      -------
      ret : numpy array, shape = m.shape
          The normalized matrix
  
      Examples
      --------
      >>> import numpy as np
      >>> from nilearn.mass_univariate.permuted_least_squares import (
      ...     normalize_matrix_on_axis)
      >>> X = np.array([[0, 4], [1, 0]])
      >>> normalize_matrix_on_axis(X)
      array([[0., 1.],
             [1., 0.]])
      >>> normalize_matrix_on_axis(X, axis=1)
      array([[0., 1.],
             [1., 0.]])
  
      """
      if m.ndim > 2:
          raise ValueError(
              "This function only accepts 2D arrays. "
              f"An array of shape {m.shape:r} was passed."
          )
  
      if axis == 0:
          # array transposition preserves the contiguity flag of that array
          ret = (m.T / np.sqrt(np.sum(m**2, axis=0))[:, np.newaxis]).T
      elif axis == 1:
          ret = normalize_matrix_on_axis(m.T).T
      else:
          raise ValueError(f"axis(={int(axis)}) out of bounds")
      return ret
  
file_path: nilearn/nilearn/mass_univariate/_utils.py
imports: import numpy
  from scipy import linalg
  from scipy.ndimage import label
label_desc: Use image node_id 4 for calling a global function with example usage: normalize_matrix_on_axis(m, axis) and returns: ret