class_docstr: One layer of CARE-GNN.
class_docstr_tok: ["One","layer","of","CARE-GNN","."]
code: def forward(self, g, feat):
      with g.local_scope():
          g.ndata["h"] = feat
  
          hr = {}
          for i, etype in enumerate(g.canonical_etypes):
              g.apply_edges(self._calc_distance, etype=etype)
              self.dist[etype] = g.edges[etype].data["d"]
              sampled_edges = self._top_p_sampling(
                  g[etype], self.p[etype]
              )
  
              # formula 8
              g.send_and_recv(
                  sampled_edges,
                  fn.copy_u("h", "m"),
                  fn.mean("m", "h_%s" % etype[1]),
                  etype=etype,
              )
              hr[etype] = g.ndata["h_%s" % etype[1]]
              if self.activation is not None:
                  hr[etype] = self.activation(hr[etype])
  
          # formula 9 using mean as inter-relation aggregator
          p_tensor = (
              th.Tensor(list(self.p.values()))
              .view(-1, 1, 1)
              .to(g.device)
          )
          h_homo = th.sum(th.stack(list(hr.values())) * p_tensor, dim=0)
          h_homo += feat
          if self.activation is not None:
              h_homo = self.activation(h_homo)
  
          return self.linear(h_homo)
  
file_path: dgl/examples/pytorch/caregnn/model.py
imports: import dgl.function
  import numpy
  import torch
  import torch.nn
label_desc: Use image node_id 4 for calling the CAREConv obj's underlying member method code with example usage: obj.forward(g, feat) and returns: self