code: def make_second_level_design_matrix(subjects_label, confounds=None):
      """Set up a second level design.
  
      Construct a design matrix with an intercept and subject specific confounds.
  
      Parameters
      ----------
      subjects_label : :obj:`list` of :obj:`str`
          Contain subject labels to extract confounders in the right order,
          corresponding with the images, to create the design matrix.
  
      confounds : :class:`pandas.DataFrame` or ``None``, default=None
          If given, contains at least two columns, ``subject_label`` and one
          confound. The subjects list determines the rows to extract from
          confounds thanks to its ``subject_label`` column. All subjects must
          have confounds specified. There should be only one row per subject.
  
      Returns
      -------
      design_matrix : :class:`pandas.DataFrame`
          The second level design matrix.
  
      """
      confounds_name = []
      if confounds is not None:
          confounds_name = confounds.columns.tolist()
          confounds_name.remove("subject_label")
  
      design_columns = confounds_name + ["intercept"]
      # check column names are unique
      if len(np.unique(design_columns)) != len(design_columns):
          raise ValueError(
              "Design matrix columns do not have unique names"
          )
  
      # float dtype necessary for linalg
      design_matrix = pd.DataFrame(columns=design_columns, dtype=float)
      for ridx, subject_label in enumerate(subjects_label):
          design_matrix.loc[ridx] = [0] * len(design_columns)
          design_matrix.loc[ridx, "intercept"] = 1
          if confounds is not None:
              conrow = confounds["subject_label"] == subject_label
              if np.sum(conrow) > 1:
                  raise ValueError(
                      "confounds contain more than one row "
                      f"for subject {subject_label}"
                  )
              elif np.sum(conrow) == 0:
                  raise ValueError(
                      f"confounds not specified for subject {subject_label}"
                  )
              for conf_name in confounds_name:
                  confounds_value = confounds[conrow][conf_name].values[
                      0
                  ]
                  design_matrix.loc[ridx, conf_name] = confounds_value
  
      # check design matrix is not singular
      sys.float_info.epsilon
      if np.linalg.cond(design_matrix.values) > design_matrix.size:
          warn(
              "Attention: Design matrix is singular. Aberrant estimates "
              "are expected."
          )
      return design_matrix
  
file_path: nilearn/nilearn/glm/first_level/design_matrix.py
imports: import sys
  from warnings import warn
  import numpy
  import pandas
  from nilearn._utils import fill_doc
  from nilearn.glm._utils import full_rank
  from nilearn.glm.first_level.experimental_paradigm import check_events, handle_modulation_of_duplicate_events
  from nilearn.glm.first_level.hemodynamic_models import compute_regressor, orthogonalize
label_desc: Use image node_id 8 for calling a global function with example usage: make_second_level_design_matrix(subjects_label, confounds) and returns: design_matrix