code: def constrained_model(data):
      locs = pyro.param(
          "locs", torch.randn(3), constraint=constraints.real
      )
      scales = pyro.param(
          "scales",
          ops.exp(torch.randn(3)),
          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)
  
imports: import warnings
  import pytest
  import torch
  from pytest import approx
  from torch.distributions import constraints
  from pyro.generic import distributions
  from pyro.generic import infer, ops, optim, pyro, pyro_backend
  from tests.common import assert_close, xfail_param
label_desc: Use image node_id 5 for calling a global function with example usage: constrained_model(data) without return types