code: def test_names(local_params):
      class Model(PyroModule):
          def __init__(self):
              super().__init__()
              self.x = nn.Parameter(torch.tensor(0.0))
              self.y = PyroParam(
                  torch.tensor(1.0), constraint=constraints.positive
              )
              self.m = nn.Module()
              self.m.u = nn.Parameter(torch.tensor(2.0))
              self.p = PyroModule()
              self.p.v = nn.Parameter(torch.tensor(3.0))
              self.p.w = PyroParam(
                  torch.tensor(4.0), constraint=constraints.positive
              )
  
          def forward(self):
              # trigger .__getattr__()
              self.x
              self.y
              self.m
              self.p.v
              self.p.w
  
      with pyro.settings.context(module_local_params=local_params):
          model = Model()
  
          # Check named_parameters.
          expected = {
              "x",
              "y_unconstrained",
              "m.u",
              "p.v",
              "p.w_unconstrained",
          }
          actual = set(name for name, _ in model.named_parameters())
          assert actual == expected
  
          # Check pyro.param names.
          expected = {"x", "y", "m$$$u", "p.v", "p.w"}
          with poutine.trace(param_only=True) as param_capture:
              model()
          actual = {
              name
              for name, site in param_capture.trace.nodes.items()
              if site["type"] == "param"
          }
          assert actual == expected
          if local_params:
              assert set(pyro.get_param_store().keys()) == set()
          else:
              assert set(pyro.get_param_store().keys()) == expected
  
          # Check pyro_parameters method
          expected = {"x", "y", "m.u", "p.v", "p.w"}
          actual = set(k for k, v in model.named_pyro_params())
          assert actual == expected
  
imports: import io
  import warnings
  import pytest
  import torch
  from torch import nn
  from torch.distributions import constraints, transform_to
  import pyro
  import pyro.distributions
  from pyro import poutine
  from pyro.infer import SVI, Trace_ELBO
  from pyro.nn.module import PyroModule, PyroParam, PyroSample, clear, to_pyro_module_
  from pyro.optim import Adam
  from tests.common import assert_equal
label_desc: Use image node_id 4 for calling a global function with example usage: test_names(local_params) without return types