code: def normalize_adj(mx):
      """Normalize sparse adjacency matrix,
      A' = (D + I)^-1/2 * ( A + I ) * (D + I)^-1/2
      Row-normalize sparse matrix
      Parameters
      ----------
      mx : scipy.sparse.csr_matrix
          matrix to be normalized
      Returns
      -------
      scipy.sprase.lil_matrix
          normalized matrix
      """
  
      # TODO: maybe using coo format would be better?
      if type(mx) is not sp.lil.lil_matrix:
          mx = mx.tolil()
      if mx[0, 0] == 0:
          mx = mx + sp.eye(mx.shape[0])
      rowsum = np.array(mx.sum(1))
      r_inv = np.power(rowsum, -1 / 2).flatten()
      r_inv[np.isinf(r_inv)] = 0.0
      r_mat_inv = sp.diags(r_inv)
      mx = r_mat_inv.dot(mx)
      mx = mx.dot(r_mat_inv)
      return mx
  
file_path: AutoGL/autogl/module/model/pyg/robust/utils.py
imports: import numpy
  import scipy.sparse
  import torch
label_desc: Use image node_id 2 for calling a global function with example usage: normalize_adj(mx) and returns: mx