code: def test_clear(local_params):
      class Model(PyroModule):
          def __init__(self):
              super().__init__()
              self.x = nn.Parameter(torch.tensor(0.0))
              self.m = torch.nn.Linear(2, 3)
              self.m.weight.data.fill_(1.0)
              self.m.bias.data.fill_(2.0)
              self.p = PyroModule()
              self.p.x = nn.Parameter(torch.tensor(3.0))
  
          def forward(self):
              return [
                  x.clone()
                  for x in [
                      self.x,
                      self.m.weight,
                      self.m.bias,
                      self.p.x,
                  ]
              ]
  
      with pyro.settings.context(module_local_params=local_params):
          m = Model()
          state0 = m()
  
          # mutate
          for _, x in m.named_pyro_params():
              if hasattr(x, "unconstrained"):
                  x = x.unconstrained()
              x.data += torch.randn(x.shape)
          state1 = m()
          for x, y in zip(state0, state1):
              assert not (x == y).all()
  
          if local_params:
              assert set(pyro.get_param_store().keys()) == set()
          else:
              assert set(pyro.get_param_store().keys()) == {
                  "x",
                  "m$$$weight",
                  "m$$$bias",
                  "p.x",
              }
              clear(m)
              del m
              assert set(pyro.get_param_store().keys()) == set()
  
          m = Model()
          state2 = m()
          if local_params:
              assert set(pyro.get_param_store().keys()) == set()
          else:
              assert set(pyro.get_param_store().keys()) == {
                  "x",
                  "m$$$weight",
                  "m$$$bias",
                  "p.x",
              }
          for actual, expected in zip(state2, state0):
              assert_equal(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 11 for calling a global function with example usage: test_clear(local_params) and returns: unknown