code: def test_warning():
      data = torch.randn(4)
  
      def model():
          x = pyro.sample("x", dist.Categorical(torch.ones(3)))
          with pyro.plate("data", len(data)):
              pyro.sample("obs", dist.Normal(x.float(), 1), obs=data)
  
      model_1 = infer_discrete(model, first_available_dim=-2)
      model_2 = infer_discrete(
          model,
          first_available_dim=-2,
          strict_enumeration_warning=False,
      )
      model_3 = infer_discrete(
          config_enumerate(model), first_available_dim=-2
      )
  
      # model_1 should raise warnings.
      with warnings.catch_warnings(record=True) as w:
          warnings.simplefilter("always")
          model_1()
      assert w, "No warnings were raised"
  
      # model_2 and model_3 should both be valid.
      model_2()
      model_3()
  
imports: import logging
  import math
  import warnings
  import pytest
  import torch
  from torch.autograd import grad
  import pyro
  import pyro.distributions
  from pyro import poutine
  from pyro.infer import TraceEnum_ELBO
  from pyro.infer.discrete import TraceEnumSample_ELBO, infer_discrete
  from pyro.infer.enum import config_enumerate
  from tests.common import assert_equal
label_desc: Use image node_id 10 for calling a global function with example usage: test_warning() without return types