code: def test_reduce_moment_matching_multivariate():
      int_inputs = [("i", Bint[4])]
      real_inputs = [("x", Reals[2])]
      inputs = OrderedDict(int_inputs + real_inputs)
      int_inputs = OrderedDict(int_inputs)
      real_inputs = OrderedDict(real_inputs)
  
      loc = numeric_array(
          [[-10.0, -1.0], [+10.0, -1.0], [+10.0, +1.0], [-10.0, +1.0]]
      )
      prec_sqrt = zeros(4, 1, 1) + ops.new_eye(loc, (2,))
      white_vec = (loc[..., None, :] @ prec_sqrt)[..., 0, :]
      discrete = Tensor(zeros(4), int_inputs)
      gaussian = Gaussian(
          white_vec=white_vec, prec_sqrt=prec_sqrt, inputs=inputs
      )
      gaussian -= gaussian.log_normalizer
      joint = discrete + gaussian
      with moment_matching:
          actual = joint.reduce(ops.logaddexp, "i")
      assert_close(
          actual.reduce(ops.logaddexp), joint.reduce(ops.logaddexp)
      )
  
      expected_white_vec = zeros(2)
      expected_precision = numeric_array(
          [[1 / 101.0, 0.0], [0.0, 1 / 2.0]]
      )
      expected_prec_sqrt = ops.pow(expected_precision, 0.5)
      expected_gaussian = Gaussian(
          white_vec=expected_white_vec,
          prec_sqrt=expected_prec_sqrt,
          inputs=real_inputs,
      )
      expected_gaussian -= expected_gaussian.log_normalizer
      expected_discrete = Tensor(ops.log(numeric_array(4.0)))
      expected = expected_discrete + expected_gaussian
      assert_close(actual, expected, atol=1e-5, rtol=None)
  
imports: from collections import OrderedDict
  from functools import reduce
  import numpy
  import pytest
  import funsor.ops
  from funsor.cnf import Contraction
  from funsor.delta import Delta
  from funsor.domains import Bint, Real, Reals
  from funsor.gaussian import Gaussian
  from funsor.integrate import Integrate
  from funsor.montecarlo import MonteCarlo
  from funsor.tensor import Tensor, numeric_array
  from funsor.terms import Number, Unary, Variable, eager, moment_matching
  from funsor.testing import assert_close, randn, random_gaussian, random_tensor, xfail_if_not_implemented, zeros
  from funsor.util import get_backend
label_desc: Use image node_id 10 for calling a global function with example usage: test_reduce_moment_matching_multivariate() without return types