docstr: Compute the (semiring) sum over all structures model.
  
  Parameters:
      logpotentials : generic params (see class)
      lengths: None or b long tensor mask
      _raw (bool) : return the unconverted semiring
  
  Returns:
      v: b tensor of total sum
docstr_tok: ["Compute","the","(","semiring",")","sum","over","all","structures","model",".","Parameters",":","logpotentials",":","generic","params","(","see","class",")","lengths",":","None","or","b","long","tensor","mask","_raw","(","bool",")",":","return","the","unconverted","semiring","Returns",":","v",":","b","tensor","of","total","sum"]
code: def sum(self, logpotentials, lengths=None, _raw=False):
      """
      Compute the (semiring) sum over all structures model.
  
      Parameters:
          logpotentials : generic params (see class)
          lengths: None or b long tensor mask
          _raw (bool) : return the unconverted semiring
  
      Returns:
          v: b tensor of total sum
      """
      v = self.logpartition(logpotentials, lengths)[0]
      if _raw:
          return v
      return self.semiring.unconvert(v)
  
file_path: pytorch-struct/torch_struct/helpers.py
imports: import torch
  import math
  from .semirings import LogSemiring
label_desc: Use image node_id 7 for calling the _Struct obj's underlying member method code with example usage: obj.sum(logpotentials, lengths, _raw) and returns: self, v