class_docstr: Implements differentiable dynamic programming with a sparsemax semiring (sparsemax, +, -inf, 0).
  
  Sparse-max gradients give a more sparse set of marginal like terms.
  
  * From softmax to sparsemax- A sparse model of attention and multi-label classification :cite:`martins2016softmax`
  * Differentiable dynamic programming for structured prediction and attention :cite:`mensch2018differentiable`
class_docstr_tok: ["Implements","differentiable","dynamic","programming","with","a","sparsemax","semiring","(","sparsemax",",","+",",","-inf",",","0",")",".","Sparse-max","gradients","give","a","more","sparse","set","of","marginal","like","terms",".","*","From","softmax","to","sparsemax-","A","sparse","model","of","attention","and","multi-label","classification",":","cite",":","`","martins2016softmax","`","*","Differentiable","dynamic","programming","for","structured","prediction","and","attention",":","cite",":","`","mensch2018differentiable","`"]
code: def sum(xs, dim=-1):
      return _SimplexProject.apply(xs, dim)
  
file_path: pytorch-struct/torch_struct/semirings/sparse_max.py
imports: import torch
  from .semirings import _BaseLog
label_desc: Use image node_id 1 for calling the SparseMaxSemiring obj's underlying member method code with example usage: obj.sum(xs, dim) and returns: _SimplexProject