code: def test_optimized_plated_einsum(equation, plates, backend):
      (
          inputs,
          outputs,
          sizes,
          operands,
          funsor_operands,
      ) = make_einsum_example(equation)
      expected = pyro_einsum(
          equation, *operands, plates=plates, backend=backend
      )[0]
      actual = einsum(
          equation, *funsor_operands, plates=plates, backend=backend
      )
  
      if len(equation) < 10:
          actual_naive = naive_plated_einsum(
              equation, *funsor_operands, plates=plates, backend=backend
          )
          assert_close(actual, actual_naive)
  
      assert isinstance(actual, funsor.Tensor) and len(outputs) == 1
      if len(outputs[0]) > 0:
          actual = actual.align(tuple(outputs[0]))
  
      assert expected.shape == actual.data.shape
      assert torch.allclose(expected, actual.data)
      for output in outputs:
          for i, output_dim in enumerate(output):
              assert output_dim in actual.inputs
              assert (
                  actual.inputs[output_dim].dtype == sizes[output_dim]
              )
  
file_path: funsor/test/test_optimizer.py
imports: from collections import OrderedDict
  import pytest
  import funsor
  from funsor.domains import Bint
  from funsor.einsum import einsum, naive_contract_einsum, naive_einsum, naive_plated_einsum
  from funsor.interpretations import normalize, reflect
  from funsor.interpreter import reinterpret
  from funsor.optimizer import apply_optimizer
  from funsor.tensor import Tensor
  from funsor.terms import Variable
  from funsor.testing import assert_close, make_chain_einsum, make_einsum_example, make_hmm_einsum, make_plated_hmm_einsum
  from funsor.util import get_backend
label_desc: Use image node_id 3 for calling a global function with example usage: test_optimized_plated_einsum(equation, plates, backend) without return types