text: import torch
  from torch.nn import Parameter
  from torch_scatter import scatter_add
  from src import MessagePassing
  from torch_geometric.utils import add_remaining_self_loops
  
  from src.inits import glorot, zeros
  
  
  class GSDNFDenoise(MessagePassing):
      def __init__(self, alpha, K, improved=False, cached=False,
                   bias=True, **kwargs):
          super(GSDNFDenoise, self).__init__(aggr='add', **kwargs)
  
          self.alpha = alpha
          self.K = K
          self.improved = improved
          self.cached = cached
  
          self.reset_parameters()
  
      def reset_parameters(self):
          self.cached_result = None
          self.cached_num_edges = None
  
      @staticmethod
      def norm(edge_index, num_nodes, edge_weight=None, improved=False,
               dtype=None):
          if edge_weight is None:
              edge_weight = torch.ones((edge_index.size(1), ), dtype=dtype,
                                       device=edge_index.device)
  
          # fill_value = 1 if not improved else 2
          # edge_index, edge_weight = add_remaining_self_loops(
          #     edge_index, edge_weight, fill_value, num_nodes)
  
          row, col = edge_index
          deg = scatter_add(edge_weight, row, dim=0, dim_size=num_nodes)
          deg_inv_sqrt = deg.pow(-0.5)
          deg_inv_sqrt[deg_inv_sqrt == float('inf')] = 0
  
          return edge_index, deg_inv_sqrt[row] * edge_weight * deg_inv_sqrt[col]
  
      def forward(self, x, edge_index, edge_weight=None):
          out = x
  
          if not self.cached or self.cached_result is None:
              self.cached_num_edges = edge_index.size(1)
              edge_index, norm = self.norm(edge_index, x.size(0), edge_weight,
                                           self.improved, x.dtype)
              self.cached_result = edge_index, norm
  
          self.cached_num_edges = edge_index.size(1)
          edge_index, norm = self.norm(edge_index, x.size(0), edge_weight,
                                          self.improved, x.dtype)
          self.cached_result = edge_index, norm
  
          edge_index, norm = self.cached_result
          
          for _ in range(self.K):
              out = self.alpha * self.propagate(edge_index, x=out, norm=norm) + x
          out = (1 - self.alpha) * out
  
          return out
  
      def message(self, x_j, norm):
          return norm.view(-1, 1) * x_j
  
      def __repr__(self):
          return '{}({}, {})'.format(self.__class__.__name__, self.in_channels,
                                     self.out_channels)
  