code: def test_joint_shape(
      sample_inputs, int_event_inputs, real_event_inputs
  ):
      event_inputs = int_event_inputs + real_event_inputs
      discrete_inputs = OrderedDict(int_event_inputs)
      gaussian_inputs = OrderedDict(event_inputs)
      expected_inputs = OrderedDict(sample_inputs + event_inputs)
      sample_inputs = OrderedDict(sample_inputs)
      event_inputs = OrderedDict(event_inputs)
      t = random_tensor(discrete_inputs)
      g = random_gaussian(gaussian_inputs)
      x = t + g  # Joint(discrete=t, gaussian=g)
  
      rng_key = subkey = (
          None
          if get_backend() == "torch"
          else np.array([0, 0], dtype=np.uint32)
      )
      xfail = False
      for num_sampled in range(len(event_inputs)):
          for sampled_vars in itertools.combinations(
              list(event_inputs), num_sampled
          ):
              sampled_vars = frozenset(sampled_vars)
              print("sampled_vars: {}".format(", ".join(sampled_vars)))
              try:
                  if rng_key is not None:
                      import jax
  
                      rng_key, subkey = jax.random.split(rng_key)
  
                  y = x.sample(
                      sampled_vars, sample_inputs, rng_key=subkey
                  )
              except NotImplementedError:
                  xfail = True
                  continue
              if sampled_vars:
                  assert dict(y.inputs) == dict(
                      expected_inputs
                  ), sampled_vars
              else:
                  assert y is x
      if xfail:
          pytest.xfail(reason="Not implemented")
  
imports: import itertools
  import math
  from collections import OrderedDict
  from importlib import import_module
  import numpy
  import pytest
  import funsor.ops
  from funsor.cnf import Contraction
  from funsor.delta import Delta
  from funsor.distribution import BACKEND_TO_DISTRIBUTIONS_BACKEND
  from funsor.domains import Bint, Real, Reals
  from funsor.integrate import Integrate
  from funsor.montecarlo import MonteCarlo
  from funsor.tensor import Tensor, align_tensors
  from funsor.terms import Variable
  from funsor.testing import assert_close, excludes_backend, id_from_inputs, randn, random_gaussian, random_tensor, xfail_if_not_implemented
  from funsor.util import get_backend
label_desc: Use image node_id 4 for calling a global function with example usage: test_joint_shape(sample_inputs, int_event_inputs, real_event_inputs) without return types