code: def einsum(eqn, *terms, **kwargs):
      r"""
      Top-level interface for optimized tensor variable elimination.
  
      :param str equation: An einsum equation.
      :param funsor.terms.Funsor \*terms: One or more operands.
      :param set plates: Optional keyword argument denoting which funsor
          dimensions are plate dimensions. Among all input dimensions (from
          terms): dimensions in plates but not in outputs are product-reduced;
          dimensions in neither plates nor outputs are sum-reduced.
      """
      with lazy:
          naive_ast = naive_plated_einsum(eqn, *terms, **kwargs)
      return apply_optimizer(naive_ast)
  
file_path: funsor/funsor/einsum/__init__.py
imports: from functools import reduce
  import funsor.ops
  from funsor.cnf import Contraction
  from funsor.optimizer import apply_optimizer
  from funsor.sum_product import sum_product
  from funsor.terms import Funsor, Variable, lazy
label_desc: Use image node_id 4 for calling a global function with example usage: einsum(eqn) and returns: apply_optimizer