class_docstr: Abstract tensor ring class.
  
  Each tensor ring class has a notion of ``dims`` that can be sum-contracted
  out, and a notion of ``ordinal`` that represents a set of plate dimensions
  that can be broadcasted-up or product-contracted out.
  Implementations should cache intermediate results to be compatible with
  :func:`~opt_einsum.shared_intermediates`.
  
  Dims are characters (string or unicode).
  Ordinals are frozensets of characters.
  
  :param dict cache: an optional :func:`~opt_einsum.shared_intermediates`
      cache.
class_docstr_tok: ["Abstract","tensor","ring","class",".","Each","tensor","ring","class","has","a","notion","of","``","dims","``","that","can","be","sum-contracted","out",",","and","a","notion","of","``","ordinal","``","that","represents","a","set","of","plate","dimensions","that","can","be","broadcasted-up","or","product-contracted","out",".","Implementations","should","cache","intermediate","results","to","be","compatible","with",":","func",":","`","~opt_einsum.shared_intermediates","`",".","Dims","are","characters","(","string","or","unicode",")",".","Ordinals","are","frozensets","of","characters",".",":","param","dict","cache",":","an","optional",":","func",":","`","~opt_einsum.shared_intermediates","`","cache","."]
code: def __init__(self, cache=None):
      self._cache = {} if cache is None else cache
  
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 1 to create a new Ring object from inherited base classes: object with example: obj = Ring(cache)