code: def test_make_op_1(batch_shape):
      inputs = OrderedDict(
          (k, Bint[s]) for k, s in zip("abc", batch_shape)
      )
  
      weights = randn(28 * 28, 2 * 20)
      bias = randn(2 * 20)
  
      @make_op
      def encode(image: Reals[28, 28]) -> Product[Reals[20], Reals[20]]:
          batch_shape = image.shape[:-2]
          loc_scale = (
              image.reshape(*batch_shape, 28 * 28) @ weights + bias
          )
          loc_scale = loc_scale.reshape(*batch_shape, 2, 20)
          loc = loc_scale[..., 0, :]
          scale = loc_scale[..., 1, :]
          assert loc.shape == batch_shape + (20,)
          assert scale.shape == batch_shape + (20,)
          return loc, scale
  
      # Check symbolic.
      image = Variable("image", Reals[28, 28])
      actual = encode(image)
      assert isinstance(actual, Unary)
      assert actual.output == Product[Reals[20], Reals[20]]
  
      # Check on ground term.
      image_data = randn(*batch_shape, 28, 28)
      actual_data = encode(image_data)
      assert isinstance(actual_data, tuple)
      assert len(actual_data) == 2
      assert isinstance(actual_data[0], type(image_data))
      assert isinstance(actual_data[1], type(image_data))
  
      # Check on funsor.Tensors.
      image = Tensor(image_data, inputs)
      actual = encode(image)
      assert isinstance(actual, Tuple)
      assert len(actual) == 2
      assert isinstance(actual[0], Tensor)
      assert isinstance(actual[1], Tensor)
      assert_close(actual[0].data, actual_data[0])
      assert_close(actual[1].data, actual_data[1])
  
file_path: funsor/test/test_op_factory.py
imports: from collections import OrderedDict
  import pytest
  from funsor.domains import Array, Bint, Dependent, Product, Reals
  from funsor.op_factory import make_op
  from funsor.tensor import Tensor
  from funsor.terms import Binary, Tuple, Unary, Variable
  from funsor.testing import assert_close, randn, requires_backend
label_desc: Use image node_id 1 for calling a global function with example usage: test_make_op_1(batch_shape) and returns: loc,  scale