code: def _sym_inv_sm(x, reduce_rank, inversion, sk):
      """Symmetric inversion with single- or matrix-style inversion."""
      if x.shape[1:] == (1, 1):
          with np.errstate(divide="ignore", invalid="ignore"):
              x_inv = 1.0 / x
          x_inv[~np.isfinite(x_inv)] = 1.0
      else:
          assert x.shape[1:] == (3, 3)
          if inversion == "matrix":
              x_inv = _sym_mat_pow(x, -1, reduce_rank=reduce_rank)
              # Reapply source covariance after inversion
              x_inv *= sk[:, :, np.newaxis]
              x_inv *= sk[:, np.newaxis, :]
          else:
              # Invert for each dipole separately using plain division
              diags = np.diagonal(x, axis1=1, axis2=2)
              assert not reduce_rank  # guaranteed earlier
              with np.errstate(divide="ignore"):
                  diags = 1.0 / diags
              # set the diagonal of each 3x3
              x_inv = np.zeros_like(x)
              for k in range(x.shape[0]):
                  this = diags[k]
                  # Reapply source covariance after inversion
                  this *= sk[k] * sk[k]
                  x_inv[k].flat[::4] = this
      return x_inv
  
imports: from copy import deepcopy
  import numpy
  from .._fiff.proj import Projection, make_projector
  from ..cov import Covariance, make_ad_hoc_cov
  from ..forward.forward import _restrict_forward_to_src_sel, is_fixed_orient
  from ..minimum_norm.inverse import _get_vertno, _prepare_forward
  from ..source_space._source_space import label_src_vertno_sel
  from ..time_frequency.csd import CrossSpectralDensity
  from ..utils import _check_option, _check_src_normal, _import_h5io_funcs, _pl, _reg_pinv, _sym_mat_pow, check_fname, logger, verbose, warn
label_desc: Use image node_id 5 for calling a global function with example usage: _sym_inv_sm(x, reduce_rank, inversion, sk) and returns: x_inv