class_docstr: Ring of sum-product operations in log space.
  
  Tensor values are in log units, so ``sum`` is implemented as ``logsumexp``,
  and ``product`` is implemented as ``sum``.
  Tensor dimensions are packed; to read the name of a tensor, read the
  ``._pyro_dims`` attribute, which is a string of dimension names aligned
  with the tensor's shape.
class_docstr_tok: ["Ring","of","sum-product","operations","in","log","space",".","Tensor","values","are","in","log","units",",","so","``","sum","``","is","implemented","as","``","logsumexp","``",",","and","``","product","``","is","implemented","as","``","sum","``",".","Tensor","dimensions","are","packed",";","to","read","the","name","of","a","tensor",",","read","the","``","._pyro_dims","``","attribute",",","which","is","a","string","of","dimension","names","aligned","with","the","tensor","'s","shape","."]
code: def sumproduct(self, terms, dims):
      inputs = [term._pyro_dims for term in terms]
      output = "".join(sorted(set("".join(inputs)) - set(dims)))
      equation = ",".join(inputs) + "->" + output
      term = contract(equation, *terms, backend=self._backend)
      term._pyro_dims = output
      return term
  
imports: import weakref
  from abc import ABCMeta, abstractmethod
  import torch
  from pyro.ops.einsum import contract
  from pyro.ops.einsum.adjoint import SAMPLE_SYMBOL, Backward
  from pyro.util import ignore_jit_warnings
label_desc: Use image node_id 2 for calling the LogRing obj's underlying member method code with example usage: obj.sumproduct(terms, dims) and returns: term