code: def generate_group_sparse_gaussian_graphs(
      n_subjects=5,
      n_features=30,
      min_n_samples=30,
      max_n_samples=50,
      density=0.1,
      random_state=0,
      verbose=0,
  ):
      """Generate signals drawn from a sparse Gaussian graphical model.
  
      Parameters
      ----------
      n_subjects : :obj:`int`, default=5
          Number of subjects.
  
      n_features : :obj:`int`, default=30
          Number of signals per subject to generate.
  
      min_n_samples, max_n_samples : :obj:`int`, optional
          Each subject have a different number of samples, between these two
          numbers. All signals for a given subject have the same number of
          samples. Defaults are 30 and 50.
  
      density : :obj:`float`, default=0.1
          Density of edges in graph topology.
  
      random_state : :obj:`int` or :obj:`numpy.random.RandomState` instance, \
                     default=0
          Random number generator, or seed.
  
      verbose : :obj:`int`, default=0
          Verbosity level (0 means no message).
  
      Returns
      -------
      signals : :obj:`list` of :obj:`numpy.ndarray`, shape for each \
          (n_samples, n_features) signals[n] is the signals for subject n.
          They are provided as a numpy len(signals) = n_subjects.
          n_samples varies according to the subject.
  
      precisions : :obj:`list` of :obj:`numpy.ndarray`
          Precision matrices.
  
      topology : :obj:`numpy.ndarray`
          Binary array giving the graph topology used for generating covariances
          and signals.
  
      """
      rand_gen = np.random.default_rng(random_state)
      # Generate topology (upper triangular binary matrix, with zeros on the
      # diagonal)
      topology = np.empty((n_features, n_features))
      topology[:, :] = np.triu(
          (
              rand_gen.integers(
                  0,
                  high=int(1.0 / density),
                  size=n_features * n_features,
              )
          ).reshape(n_features, n_features)
          == 0,
          k=1,
      )
  
      # Generate edges weights on topology
      precisions = []
      mask = topology > 0
      for _ in range(n_subjects):
          # See also sklearn.datasets.samples_generator.make_sparse_spd_matrix
          prec = topology.copy()
          prec[mask] = rand_gen.uniform(
              low=0.1, high=0.8, size=(mask.sum())
          )
          prec += np.eye(prec.shape[0])
          prec = np.dot(prec.T, prec)
  
          # Assert precision matrix is spd
          np.testing.assert_almost_equal(prec, prec.T)
          eigenvalues = np.linalg.eigvalsh(prec)
          if eigenvalues.min() < 0:
              raise ValueError(
                  "Failed generating a positive definite precision "
                  "matrix. Decreasing n_features can help solving "
                  "this problem."
              )
          precisions.append(prec)
  
      # Returns the topology matrix of precision matrices.
      topology += np.eye(*topology.shape)
      topology = np.dot(topology.T, topology)
      topology = topology > 0
      assert np.all(topology == topology.T)
      logger.log(
          f"Sparsity: {1.0 * topology.sum() / topology.shape[0] ** 2 :f}",
          verbose=verbose,
      )
  
      # Generate temporal signals
      signals = _generate_signals_from_precisions(
          precisions,
          min_n_samples=min_n_samples,
          max_n_samples=max_n_samples,
          random_state=rand_gen,
      )
      return signals, precisions, topology
  
imports: from __future__ import annotations
  import itertools
  import json
  import string
  from pathlib import Path
  import numpy
  import pandas
  import scipy.linalg
  import scipy.signal
  from nibabel import Nifti1Image
  from scipy.ndimage import binary_dilation
  from nilearn import datasets, image, maskers, masking
  from nilearn._utils import as_ndarray, logger
  from nilearn.interfaces.bids.utils import bids_entities, check_bids_label, create_bids_filename
  from nilearn.interfaces.fmriprep.tests._testing import get_legal_confound
label_desc: Use image node_id 12 for calling a global function with example usage: generate_group_sparse_gaussian_graphs(n_subjects, n_features, min_n_samples, max_n_samples, density, random_state, verbose) and returns: signals,  precisions,  topology