class_docstr: A container for sums of Tensors among different :class:`plate` contexts.
  
  Used in :class:`~pyro.infer.tracegraph_elbo.TraceGraph_ELBO` to simplify
  downstream cost computation logic.
  
  Example::
  
      downstream_cost = MultiFrameTensor()
      for site in downstream_nodes:
          downstream_cost.add((site["cond_indep_stack"], site["log_prob"]))
      downstream_cost.add(*other_costs.items())  # add in bulk
      summed = downstream_cost.sum_to(target_site["cond_indep_stack"])
docstr: Add a collection of (cond_indep_stack, tensor) pairs. Keys are
  ``cond_indep_stack``s, i.e. tuples of :class:`CondIndepStackFrame`s.
  Values are :class:`torch.Tensor`s.
docstr_tok: ["Add","a","collection","of","(","cond_indep_stack",",","tensor",")","pairs",".","Keys","are","``","cond_indep_stack","``","s",",","i.e",".","tuples","of",":","class",":","`","CondIndepStackFrame","`","s",".","Values","are",":","class",":","`","torch.Tensor","`","s","."]
code: def add(self, *items):
      """
      Add a collection of (cond_indep_stack, tensor) pairs. Keys are
      ``cond_indep_stack``s, i.e. tuples of :class:`CondIndepStackFrame`s.
      Values are :class:`torch.Tensor`s.
      """
      for cond_indep_stack, value in items:
          frames = frozenset(
              f for f in cond_indep_stack if f.vectorized
          )
          assert all(
              f.dim < 0 and -value.dim() <= f.dim for f in frames
          )
          if frames in self:
              self[frames] = self[frames] + value
          else:
              self[frames] = value
  
imports: import math
  import numbers
  from collections import Counter, defaultdict
  from contextlib import contextmanager
  import torch
  from opt_einsum import shared_intermediates
  from opt_einsum.sharing import count_cached_ops
  from pyro.distributions.util import is_identically_zero
  from pyro.ops import packed
  from pyro.ops.einsum.adjoint import require_backward
  from pyro.ops.rings import MarginalRing
  from pyro.poutine.util import site_is_subsample
  from ..None import settings
label_desc: Use image node_id 2 for calling the MultiFrameTensor obj's underlying member method code with example usage: obj.add() without return types