code: def test_einsum(equation, min_size, infinite):
      inputs, output = equation.split("->")
      inputs = inputs.split(",")
      symbols = sorted(set(equation) - set(",->"))
      sizes = dict(zip(symbols, itertools.count(min_size)))
      shapes = [
          torch.Size(tuple(sizes[dim] for dim in dims))
          for dims in inputs
      ]
      operands = [
          torch.full(shape, -float("inf"))
          if infinite
          else torch.randn(shape)
          for shape in shapes
      ]
  
      expected = contract(
          equation, *(torch_exp(x) for x in operands), backend="torch"
      ).log()
      actual = contract(
          equation, *operands, backend="pyro.ops.einsum.torch_log"
      )
      assert_equal(actual, expected)
  
imports: import itertools
  import pytest
  import torch
  from pyro.infer.util import torch_exp
  from pyro.ops.einsum import contract
  from tests.common import assert_equal
label_desc: Use image node_id 1 for calling a global function with example usage: test_einsum(equation, min_size, infinite) without return types