class_docstr: Ring of sum-product operations in linear space.
  
  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","linear","space",".","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 product(self, term, ordinal):
      dims = term._pyro_dims
      for dim in sorted(ordinal, reverse=True):
          pos = dims.find(dim)
          if pos != -1:
              key = "product", self._hash_by_id(term), dim
              if key in self._cache:
                  term = self._cache[key]
              else:
                  term = term.prod(pos)
                  dims = dims.replace(dim, "")
                  self._cache[key] = term
                  term._pyro_dims = dims
      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 3 for calling the LinearRing obj's underlying member method code with example usage: obj.product(term, ordinal) and returns: term