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","."]
docstr: Computes global and local terms for tensor message passing
  using inclusion-exclusion::
  
      term / sum(term, dims) * product(sum(term, dims), ordinal)
      \____________________/   \_______________________________/
            local part                    global part
  
  :param torch.Tensor term: the term to contract
  :param dims: an iterable of sum dims to contract
  :param frozenset ordinal: an ordinal specifying plates to contract
  :return: a tuple ``(global_part, local_part)`` as defined above
  :rtype: tuple
code: def global_local(self, term, dims, ordinal):
      r"""
      Computes global and local terms for tensor message passing
      using inclusion-exclusion::
  
          term / sum(term, dims) * product(sum(term, dims), ordinal)
          \____________________/   \_______________________________/
                local part                    global part
  
      :param torch.Tensor term: the term to contract
      :param dims: an iterable of sum dims to contract
      :param frozenset ordinal: an ordinal specifying plates to contract
      :return: a tuple ``(global_part, local_part)`` as defined above
      :rtype: tuple
      """
      assert dims, "dims was empty, use .product() instead"
      key = (
          "global_local",
          self._hash_by_id(term),
          frozenset(dims),
          ordinal,
      )
      if key in self._cache:
          return self._cache[key]
  
      term_sum = self.sumproduct([term], dims)
      global_part = self.product(term_sum, ordinal)
      with ignore_jit_warnings():
          local_part = self.sumproduct(
              [term, self.inv(term_sum)], set()
          )
      assert sorted(local_part._pyro_dims) == sorted(term._pyro_dims)
      result = global_part, local_part
      self._cache[key] = result
      return result
  
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 7 for calling the Ring obj's underlying member method code with example usage: obj.global_local(term, dims, ordinal) and returns: result, self