code: def test_adjoint_shape(backend, equation, plates):
      backend = "pyro.ops.einsum.torch_{}".format(backend)
      inputs, output = equation.split("->")
      inputs = inputs.split(",")
      operands = [
          torch.randn(torch.Size((2,) * len(input_)))
          for input_ in inputs
      ]
      for input_, x in zip(inputs, operands):
          x._pyro_dims = input_
  
      # run forward-backward algorithm
      for x in operands:
          require_backward(x)
      (result,) = ubersum(
          equation,
          *operands,
          plates=plates,
          modulo_total=True,
          backend=backend,
      )
      result._pyro_backward()
  
      for input_, x in zip(inputs, operands):
          backward_result = x._pyro_backward_result
          contract_dims = set(input_) - set(output) - set(plates)
          if contract_dims:
              assert backward_result is not None
          else:
              assert backward_result is None
  
imports: import itertools
  import numbers
  from collections import OrderedDict
  import opt_einsum
  import pytest
  import torch
  import pyro.ops.jit
  from pyro.distributions.util import logsumexp
  from pyro.ops.contract import _partition_terms, contract_tensor_tree, contract_to_tensor, einsum, naive_ubersum, ubersum
  from pyro.ops.einsum.adjoint import require_backward
  from pyro.ops.rings import LogRing
  from pyro.poutine.indep_messenger import CondIndepStackFrame
  from pyro.util import optional
  from tests.common import assert_equal
label_desc: Use image node_id 27 for calling a global function with example usage: test_adjoint_shape(backend, equation, plates) without return types