code: def _dimensionality_reduction(cov_signal, cov_noise, info, rank):
      """Perform dimensionality reduction on the covariance matrices."""
      n_channels = cov_signal.shape[0]
  
      # find ranks of covariance matrices
      rank_signal = list(
          compute_rank(
              Covariance(
                  cov_signal,
                  info.ch_names,
                  list(),
                  list(),
                  0,
                  verbose=_verbose_safe_false(),
              ),
              rank,
              _handle_default("scalings_cov_rank", None),
              info,
          ).values()
      )[0]
      rank_noise = list(
          compute_rank(
              Covariance(
                  cov_noise,
                  info.ch_names,
                  list(),
                  list(),
                  0,
                  verbose=_verbose_safe_false(),
              ),
              rank,
              _handle_default("scalings_cov_rank", None),
              info,
          ).values()
      )[0]
      rank = np.min([rank_signal, rank_noise])  # should be identical
  
      if rank < n_channels:
          eigvals, eigvects = eigh(cov_signal)
          # sort in descending order
          ix = np.argsort(eigvals)[::-1]
          eigvals = eigvals[ix]
          eigvects = eigvects[:, ix]
          # compute rank subspace projection matrix
          rank_proj = np.matmul(
              eigvects[:, :rank],
              np.eye(rank) * (eigvals[:rank] ** -0.5),
          )
          logger.info(
              "Projecting covariance of %i channels to %i rank subspace"
              % (
                  n_channels,
                  rank,
              )
          )
      else:
          rank_proj = np.eye(n_channels)
          logger.info("Preserving covariance rank (%i)" % (rank,))
  
      # project covariance matrices to rank subspace
      cov_signal = np.matmul(
          rank_proj.T, np.matmul(cov_signal, rank_proj)
      )
      cov_noise = np.matmul(
          rank_proj.T, np.matmul(cov_noise, rank_proj)
      )
      return cov_signal, cov_noise, rank_proj
  
imports: import numpy
  from scipy.linalg import eigh
  from .._fiff.pick import _picks_to_idx
  from ..cov import Covariance, _regularized_covariance
  from ..defaults import _handle_default
  from ..filter import filter_data
  from ..fixes import BaseEstimator
  from ..rank import compute_rank
  from ..time_frequency import psd_array_welch
  from ..utils import _check_option, _time_mask, _validate_type, _verbose_safe_false, fill_doc, logger
  from .mixin import TransformerMixin
label_desc: Use image node_id 1 for calling a global function with example usage: _dimensionality_reduction(cov_signal, cov_noise, info, rank) and returns: cov_signal,  cov_noise,  rank_proj