class_docstr: Implements a sampling semiring (logsumexp, +, -inf, 0).
  
  "Gradients" give sample.
  
  This is an exact forward-filtering, backward-sampling approach.
class_docstr_tok: ["Implements","a","sampling","semiring","(","logsumexp",",","+",",","-inf",",","0",")",".","``","Gradients","''","give","sample",".","This","is","an","exact","forward-filtering",",","backward-sampling","approach","."]
code: def sum(xs, dim=-1):
      return _SampledLogSumExp.apply(xs, dim)
  
file_path: pytorch-struct/torch_struct/semirings/sample.py
imports: import torch
  import torch.distributions
  from .semirings import _BaseLog
label_desc: Use image node_id 1 for calling the SampledSemiring obj's underlying member method code with example usage: obj.sum(xs, dim) and returns: _SampledLogSumExp