code: def att_coef(self, fea, edge_index, is_lil=False, i=0):
      if is_lil == False:
          edge_index = edge_index._indices()
      else:
          edge_index = edge_index.tocoo()
  
      n_node = fea.shape[0]
      row, col = (
          edge_index[0].cpu().data.numpy()[:],
          edge_index[1].cpu().data.numpy()[:],
      )
  
      fea_copy = fea.cpu().data.numpy()
      sim_matrix = cosine_similarity(
          X=fea_copy, Y=fea_copy
      )  # try cosine similarity
      sim = sim_matrix[row, col]
      sim[sim < 0.1] = 0
      # print('dropped {} edges'.format(1-sim.nonzero()[0].shape[0]/len(sim)))
  
      # """use jaccard for binary features and cosine for numeric features"""
      # fea_start, fea_end = fea[edge_index[0]], fea[edge_index[1]]
      # isbinray = np.array_equal(fea_copy, fea_copy.astype(bool))  # check is the fea are binary
      # np.seterr(divide='ignore', invalid='ignore')
      # if isbinray:
      #     fea_start, fea_end = fea_start.T, fea_end.T
      #     sim = jaccard_score(fea_start, fea_end, average=None)  # similarity scores of each edge
      # else:
      #     fea_copy[np.isinf(fea_copy)] = 0
      #     fea_copy[np.isnan(fea_copy)] = 0
      #     sim_matrix = cosine_similarity(X=fea_copy, Y=fea_copy)  # try cosine similarity
      #     sim = sim_matrix[edge_index[0], edge_index[1]]
      #     sim[sim < 0.01] = 0
  
      """build a attention matrix"""
      att_dense = lil_matrix((n_node, n_node), dtype=np.float32)
      att_dense[row, col] = sim
      if att_dense[0, 0] == 1:
          att_dense = att_dense - sp.diags(
              att_dense.diagonal(), offsets=0, format="lil"
          )
      # normalization, make the sum of each row is 1
      att_dense_norm = normalize(att_dense, axis=1, norm="l1")
  
      """add learnable dropout, make character vector"""
      if self.drop:
          character = np.vstack(
              (att_dense_norm[row, col].A1, att_dense_norm[col, row].A1)
          )
          character = torch.from_numpy(character.T)
          drop_score = self.drop_learn_1(character)
          drop_score = torch.sigmoid(
              drop_score
          )  # do not use softmax since we only have one element
          mm = torch.nn.Threshold(0.5, 0)
          drop_score = mm(drop_score)
          mm_2 = torch.nn.Threshold(-0.49, 1)
          drop_score = mm_2(-drop_score)
          drop_decision = drop_score.clone().requires_grad_()
          # print('rate of left edges', drop_decision.sum().data/drop_decision.shape[0])
          drop_matrix = lil_matrix((n_node, n_node), dtype=np.float32)
          drop_matrix[row, col] = (
              drop_decision.cpu().data.numpy().squeeze(-1)
          )
          att_dense_norm = att_dense_norm.multiply(
              drop_matrix.tocsr()
          )  # update, remove the 0 edges
  
      if (
          att_dense_norm[0, 0] == 0
      ):  # add the weights of self-loop only add self-loop at the first layer
          degree = (att_dense_norm != 0).sum(1).A1
          lam = 1 / (degree + 1)  # degree +1 is to add itself
          self_weight = sp.diags(np.array(lam), offsets=0, format="lil")
          att = att_dense_norm + self_weight  # add the self loop
      else:
          att = att_dense_norm
  
      row, col = att.nonzero()
      att_adj = np.vstack((row, col))
      att_edge_weight = att[row, col]
      att_edge_weight = np.exp(
          att_edge_weight
      )  # exponent, kind of softmax
      att_edge_weight = torch.tensor(
          np.array(att_edge_weight)[0], dtype=torch.float32
      )  # .cuda()
      att_adj = torch.tensor(att_adj, dtype=torch.int64)  # .cuda()
  
      shape = (n_node, n_node)
      new_adj = torch.sparse.FloatTensor(
          att_adj, att_edge_weight, shape
      )
      return new_adj
  
imports: import numpy
  from copy import deepcopy
  from numba import njit
  import torch.nn
  import torch.nn.functional
  import math
  import torch
  import torch.optim
  import typing
  from torch_geometric.data import Data
  from sklearn.metrics.pairwise import euclidean_distances, cosine_similarity
  from scipy.sparse import lil_matrix
  from sklearn.preprocessing import normalize
  import scipy.sparse
  import autogl.data
  from ..None import register_model
  from .None import utils
  from ..gcn import GCN
  from .nn import GCNConv
  from ..base import BaseAutoModel
  from .....utils import get_logger
  from .utils import accuracy
label_desc: Use image node_id 3 for calling the GCN4GNNGuard obj's underlying member method code with example usage: obj.att_coef(fea, edge_index, is_lil, i) and returns: new_adj