code: def test_constraints(backend, jit):
      data = torch.tensor(0.5)
  
      def model():
          locs = pyro.param(
              "locs", torch.randn(3), constraint=constraints.real
          )
          scales = pyro.param(
              "scales",
              torch.randn(3).exp(),
              constraint=constraints.positive,
          )
          p = torch.tensor([0.5, 0.3, 0.2])
          x = pyro.sample("x", dist.Categorical(p))
          pyro.sample("obs", dist.Normal(locs[x], scales[x]), obs=data)
  
      def guide():
          q = pyro.param(
              "q", torch.randn(3).exp(), constraint=constraints.simplex
          )
          pyro.sample("x", dist.Categorical(q))
  
      with pyro_backend(backend):
          Elbo = infer.JitTrace_ELBO if jit else infer.Trace_ELBO
          elbo = Elbo(ignore_jit_warnings=True)
          assert_ok(model, guide, elbo)
  
imports: import warnings
  import pytest
  import funsor
  from funsor.testing import xfail_param
  from funsor.util import get_backend
label_desc: Use image node_id 15 for calling a global function with example usage: test_constraints(backend, jit) without return types