class_docstr: Declarative representation of a finitary sum-product operation.
  
  After normalization via the :func:`~funsor.terms.normalize` interpretation
  contractions will canonically order their terms by type::
  
      Delta, Number, Tensor, Gaussian
class_docstr_tok: ["Declarative","representation","of","a","finitary","sum-product","operation",".","After","normalization","via","the",":","func",":","`","~funsor.terms.normalize","`","interpretation","contractions","will","canonically","order","their","terms","by","type",":",":","Delta",",","Number",",","Tensor",",","Gaussian"]
code: def align(self, names):
      assert isinstance(names, tuple)
      assert all(name in self.inputs for name in names)
      new_terms = tuple(
          t.align(tuple(n for n in names if n in t.inputs))
          for t in self.terms
      )
      result = Contraction(
          self.red_op, self.bin_op, self.reduced_vars, *new_terms
      )
      if not names == tuple(result.inputs):
          return Align(
              result, names
          )  # raise NotImplementedError("TODO align all terms")
      return result
  
imports: import functools
  import itertools
  from collections import Counter, OrderedDict, defaultdict
  from functools import reduce
  from typing import Tuple, Union
  import opt_einsum
  import funsor
  import funsor.ops
  from funsor.affine import affine_inputs
  from funsor.delta import Delta
  from funsor.domains import find_domain
  from funsor.gaussian import Gaussian
  from funsor.interpretations import eager, normalize, reflect
  from funsor.interpreter import children
  from funsor.ops import DISTRIBUTIVE_OPS, AssociativeOp, NullOp
  from funsor.tensor import Tensor
  from funsor.terms import _INFIX, Align, Binary, Funsor, Number, Reduce, Subs, Unary, Variable, to_funsor
  from funsor.typing import Variadic
  from funsor.util import broadcast_shape, get_backend, quote
label_desc: Use image node_id 5 for calling the Contraction obj's underlying member method code with example usage: obj.align(names) and returns: result, Align