code: def _rectify_resolution_matrix(resmat):
      """
      Ensure resolution matrix is square matrix.
  
      If resmat is not a square matrix, it is assumed that the inverse operator
      had free or loose orientation constraint, i.e. multiple values per source
      location. The Euclidean length for values at each location is computed to
      make resmat a square matrix.
      """
      shape = resmat.shape
      if not shape[0] == shape[1]:
          if shape[0] < shape[1]:
              raise ValueError(
                  "Number of target sources (%d) cannot be lower "
                  "than number of input sources (%d)" % shape[0],
                  shape[1],
              )
  
          if np.mod(shape[0], shape[1]):  # if ratio not integer
              raise ValueError(
                  "Number of target sources (%d) must be a "
                  "multiple of the number of input sources (%d)"
                  % shape[0],
                  shape[1],
              )
  
          ns = (
              shape[0] // shape[1]
          )  # number of source components per vertex
  
          # Combine rows of resolution matrix
          resmatl = [
              np.sqrt(
                  (resmat[ns * i : ns * (i + 1), :] ** 2).sum(axis=0)
              )
              for i in np.arange(0, shape[1], dtype=int)
          ]
  
          resmat = np.array(resmatl)
  
          logger.info(
              "Rectified resolution matrix from (%d, %d) to (%d, %d)."
              % (shape[0], shape[1], resmat.shape[0], resmat.shape[1])
          )
  
      return resmat
  
file_path: mne-python/mne/minimum_norm/spatial_resolution.py
imports: import numpy
  from ..source_estimate import SourceEstimate
  from ..utils import _check_option, logger, verbose
label_desc: Use image node_id 6 for calling a global function with example usage: _rectify_resolution_matrix(resmat) and returns: resmat