code: def _iter_contrasts(n_subjects, factor_levels, effect_picks):
      """Set up contrasts."""
      sc = []
      n_factors = len(factor_levels)
      # prepare computation of Kronecker products
      for n_levels in factor_levels:
          # for each factor append
          # 1) column vector of length == number of levels,
          # 2) square matrix with diagonal == number of levels
  
          # main + interaction effects for contrasts
          sc.append(
              [
                  np.ones([n_levels, 1]),
                  detrend(np.eye(n_levels), type="constant"),
              ]
          )
  
      for this_effect in effect_picks:
          contrast_idx = _get_contrast_indices(
              this_effect + 1, n_factors
          )
          c_ = sc[0][contrast_idx[n_factors - 1]]
          for i_contrast in range(1, n_factors):
              this_contrast = contrast_idx[(n_factors - 1) - i_contrast]
              c_ = np.kron(c_, sc[i_contrast][this_contrast])
          df1 = np.linalg.matrix_rank(c_)
          df2 = df1 * (n_subjects - 1)
          yield c_, df1, df2
  
file_path: mne-python/mne/stats/parametric.py
imports: from functools import reduce
  from string import ascii_uppercase
  import numpy
  from scipy import stats
  from scipy.signal import detrend
  from ..utils import _check_option
label_desc: Use image node_id 6 for calling a global function with example usage: _iter_contrasts(n_subjects, factor_levels, effect_picks) without return types