class_docstr: Description
  -----------
  Pytorch Auto-Grad Function for edge sparsemax.
  
  We define this auto-grad function here since
  sparsemax involves sort and select, which are
  not derivative.
class_docstr_tok: ["Description","--","--","--","--","--","-","Pytorch","Auto-Grad","Function","for","edge","sparsemax",".","We","define","this","auto-grad","function","here","since","sparsemax","involves","sort","and","select",",","which","are","not","derivative","."]
code: def backward(ctx, grad_out):
      gidx = ctx.backward_cache
      supp_size, out = ctx.saved_tensors
      grad_in = grad_out.clone()
  
      # grad for ReLU
      grad_in[out == 0] = 0
  
      # dL/dv_i = dL/do_i - 1/k \sum_{j=1}^k dL/do_j
      v_hat = _gspmm(gidx, "copy_rhs", "sum", None, grad_in)[
          0
      ] / supp_size.to(out.dtype)
      grad_in_modify = _gsddmm(gidx, "sub", grad_in, v_hat, "e", "v")
      grad_in = torch.where(out != 0, grad_in_modify, grad_in)
      del gidx
      torch.cuda.empty_cache()
  
      return None, grad_in, None, None, None
  
file_path: dgl/examples/pytorch/hgp_sl/functions.py
imports: import dgl
  import torch
  from dgl.backend import astype
  from dgl.base import ALL, is_all
  from dgl.heterograph_index import HeteroGraphIndex
  from dgl.sparse import _gsddmm, _gspmm
  from torch import Tensor
  from torch.autograd import Function
label_desc: Use image node_id 2 for calling the EdgeSparsemaxFunction obj's underlying member method code with example usage: obj.backward(ctx, grad_out) and returns: None,  grad_in,  None,  None,  None