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: Broadcast the given ``term`` by expanding along any plate dimensions
  present in ``ordinal`` but not ``term``.
  
  :param torch.Tensor term: the term to expand
  :param frozenset ordinal: an ordinal specifying plates
code: def broadcast(self, term, ordinal):
      """
      Broadcast the given ``term`` by expanding along any plate dimensions
      present in ``ordinal`` but not ``term``.
  
      :param torch.Tensor term: the term to expand
      :param frozenset ordinal: an ordinal specifying plates
      """
      dims = term._pyro_dims
      missing_dims = "".join(sorted(set(ordinal) - set(dims)))
      if missing_dims:
          key = "broadcast", self._hash_by_id(term), missing_dims
          if key in self._cache:
              term = self._cache[key]
          else:
              missing_shape = tuple(
                  self._dim_to_size[dim] for dim in missing_dims
              )
              term = term.expand(missing_shape + term.shape)
              dims = missing_dims + dims
              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 5 for calling the Ring obj's underlying member method code with example usage: obj.broadcast(term, ordinal) and returns: term