code: def _weighted_connectivity_graph(X, mask_img):
      """Create a symmetric weighted graph.
  
      Data and topology are encoded by a connectivity matrix.
  
      Parameters
      ----------
      X : :class:`numpy.ndarray`
          Training data. shape = [n_samples, n_features]
  
      mask_img : Niimg-like object
          Object used for masking the data.
  
      Returns
      -------
      connectivity : a CSR matrix
          Sparse matrix representation of the weighted adjacency graph.
  
      """
      n_features = X.shape[1]
  
      edges, weight = _make_edges_and_weights(X, mask_img)
  
      connectivity = coo_matrix(
          (weight, edges), (n_features, n_features)
      ).tocsr()
  
      # Making it symmetrical
      connectivity = (connectivity + connectivity.T) / 2
  
      return connectivity
  
imports: import warnings
  import numpy
  from joblib import Memory
  from nibabel import Nifti1Image
  from scipy.sparse import coo_matrix, csgraph, dia_matrix
  from sklearn.base import BaseEstimator, ClusterMixin, TransformerMixin
  from sklearn.utils import check_array
  from sklearn.utils.validation import check_is_fitted
  from nilearn._utils import fill_doc
  from nilearn.image import get_data
  from nilearn.masking import unmask_from_to_3d_array
label_desc: Use image node_id 4 for calling a global function with example usage: _weighted_connectivity_graph(X, mask_img) and returns: connectivity