code: def einsum(equation, *operands):
      """
      Forward-log-sum-product-exp backward-sample-exp implementation of einsum.
      This assumes all operands have a ``._pyro_dims`` attribute set.
      """
      equation = packed.rename_equation(equation, *operands)
      inputs, output = equation.split("->")
      result = pyro.ops.einsum.torch_log.einsum(equation, *operands)
      result._pyro_dims = output
      assert result.dim() == len(result._pyro_dims)
  
      if any(hasattr(x, "_pyro_backward") for x in operands):
          result._pyro_backward = _EinsumBackward(output, operands)
      return result
  
file_path: pyro/pyro/ops/einsum/torch_sample.py
imports: import operator
  from functools import reduce
  import pyro.distributions
  import pyro.ops.einsum.torch_log
  from pyro.ops import packed
  from pyro.ops.einsum.adjoint import Backward, einsum_backward_sample, transpose, unflatten
  from pyro.ops.einsum.util import Tensordot
  from pyro.util import jit_iter
label_desc: Use image node_id 1 for calling a global function with example usage: einsum(equation) and returns: result