We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Update paramstore documentation
Params are not properly reused from the paramstore via `.load()` since the default flag `update_module_params` is false (iirc this is because of `random_module`).  the interface/defaults should be revisited and at the very least, documentation updated.

[source](https://forum.pyro.ai/t/pyro-get-param-store-load-documentation/299)

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pyro/params/param_store.py`
Content:
```
1 from __future__ import absolute_import, division, print_function
2 
3 import weakref
4 
5 import torch
6 from torch.distributions import constraints, transform_to
7 
8 
9 class ParamStoreDict(object):
10     """
11     Global store for parameters in Pyro. This is basically a key-value store.
12     The typical user interacts with the ParamStore primarily through the
13     primitive `pyro.param`.
14 
15     See `Intro Part II <http://pyro.ai/examples/intro_part_ii.html>`_ for further discussion
16     and `SVI Part I <http://pyro.ai/examples/svi_part_i.html>`_ for some examples.
17 
18     Some things to bear in mind when using parameters in Pyro:
19 
20     - parameters must be assigned unique names
21     - the `init_tensor` argument to `pyro.param` is only used the first time that a given (named)
22       parameter is registered with Pyro.
23     - for this reason, a user may need to use the `clear()` method if working in a REPL in order to
24       get the desired behavior. this method can also be invoked with `pyro.clear_param_store()`.
25     - the internal name of a parameter within a PyTorch `nn.Module` that has been registered with
26       Pyro is prepended with the Pyro name of the module. so nothing prevents the user from having
27       two different modules each of which contains a parameter named `weight`. by contrast, a user
28       can only have one top-level parameter named `weight` (outside of any module).
29     - parameters can be saved and loaded from disk using `save` and `load`.
30     """
31 
32     def __init__(self):
33         """
34         initialize ParamStore data structures
35         """
36         self._params = {}  # dictionary from param name to param
37         self._param_to_name = {}  # dictionary from unconstrained param to param name
38         self._constraints = {}  # dictionary from param name to constraint object
39 
40     def clear(self):
41         """
42         Clear the ParamStore
43         """
44         self._params = {}
45         self._param_to_name = {}
46         self._constraints = {}
47 
48     def named_parameters(self):
49         """
50         Returns an iterator over tuples of the form (name, parameter) for each parameter in the ParamStore
51         """
52         # TODO consider returing constrained
53         return self._params.items()
54 
55     def get_all_param_names(self):
56         """
57         Get all parameter names in the ParamStore
58         """
59         return self._params.keys()
60 
61     def replace_param(self, param_name, new_param, old_param):
62         """
63         Replace the param param_name with current value old_param with the new value new_param
64 
65         :param param_name: parameter name
66         :type param_name: str
67         :param new_param: the paramater to be put into the ParamStore
68         :type new_param: torch.Tensor
69         :param old_param: the paramater to be removed from the ParamStore
70         :type new_param: torch.Tensor
71         """
72         assert self._params[param_name] is old_param.unconstrained()
73         del self._params[param_name]
74         del self._param_to_name[old_param.unconstrained()]
75         self.get_param(param_name, new_param, constraint=self._constraints[param_name])
76 
77     def get_param(self, name, init_tensor=None, constraint=constraints.real):
78         """
79         Get parameter from its name. If it does not yet exist in the
80         ParamStore, it will be created and stored.
81         The Pyro primitive `pyro.param` dispatches to this method.
82 
83         :param name: parameter name
84         :type name: str
85         :param init_tensor: initial tensor
86         :type init_tensor: torch.Tensor
87         :returns: parameter
88         :rtype: torch.Tensor
89         """
90         if name not in self._params:
91             # if not create the init tensor through
92             assert init_tensor is not None,\
93                 "cannot initialize a parameter '{}' with None. Did you get the param name right?".format(name)
94 
95             # a function
96             if callable(init_tensor):
97                 init_tensor = init_tensor()
98 
99             # store the unconstrained value and constraint
100             with torch.no_grad():
101                 unconstrained_param = transform_to(constraint).inv(init_tensor)
102             unconstrained_param.requires_grad_(True)
103             self._params[name] = unconstrained_param
104             self._constraints[name] = constraint
105 
106             # keep track of each tensor and it's name
107             self._param_to_name[unconstrained_param] = name
108 
109         elif init_tensor is not None and not callable(init_tensor):
110             if self._params[name].shape != init_tensor.shape:
111                 raise ValueError("param {} init tensor shape does not match existing value: {} vs {}".format(
112                     name, init_tensor.shape, self._params[name].shape))
113 
114         # get the guaranteed to exist param
115         unconstrained_param = self._params[name]
116 
117         # compute the constrained value
118         param = transform_to(self._constraints[name])(unconstrained_param)
119         param.unconstrained = weakref.ref(unconstrained_param)
120 
121         return param
122 
123     def param_name(self, p):
124         """
125         Get parameter name from parameter
126 
127         :param p: parameter
128         :returns: parameter name
129         """
130         if p not in self._param_to_name:
131             return None
132 
133         return self._param_to_name[p]
134 
135     def get_state(self):
136         """
137         Get the ParamStore state.
138         """
139         state = {
140             'params': self._params,
141             'constraints': self._constraints,
142         }
143         return state
144 
145     def set_state(self, state):
146         """
147         Set the ParamStore state using state from a previous get_state() call
148         """
149         assert isinstance(state, dict), "malformed ParamStore state"
150         assert set(state.keys()) == set(['params', 'constraints']), \
151             "malformed ParamStore keys {}".format(state.keys())
152 
153         for param_name, param in state['params'].items():
154             self._params[param_name] = param
155             self._param_to_name[param] = param_name
156 
157         for param_name, constraint in state['constraints'].items():
158             if isinstance(constraint, type(constraints.real)):
159                 # Work around lack of hash & equality comparison on constraints.
160                 constraint = constraints.real
161             self._constraints[param_name] = constraint
162 
163     def save(self, filename):
164         """
165         Save parameters to disk
166 
167         :param filename: file name to save to
168         :type name: str
169         """
170         with open(filename, "wb") as output_file:
171             torch.save(self.get_state(), output_file)
172 
173     def load(self, filename):
174         """
175         Loads parameters from disk
176 
177         :param filename: file name to load from
178         :type name: str
179         """
180         with open(filename, "rb") as input_file:
181             state = torch.load(input_file)
182         self.set_state(state)
183 
184 
185 # used to create fully-formed param names, e.g. mymodule$$$mysubmodule.weight
186 _MODULE_NAMESPACE_DIVIDER = "$$$"
187 
188 
189 def param_with_module_name(pyro_name, param_name):
190     return _MODULE_NAMESPACE_DIVIDER.join([pyro_name, param_name])
191 
192 
193 def module_from_param_with_module_name(param_name):
194     return param_name.split(_MODULE_NAMESPACE_DIVIDER)[0]
195 
196 
197 def user_param_name(param_name):
198     if _MODULE_NAMESPACE_DIVIDER in param_name:
199         return param_name.split(_MODULE_NAMESPACE_DIVIDER)[1]
200     return param_name
201
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pyro/params/param_store.py b/pyro/params/param_store.py
--- a/pyro/params/param_store.py
+++ b/pyro/params/param_store.py
@@ -174,6 +174,14 @@
         """
         Loads parameters from disk
 
+        .. note::
+
+           If using :meth:`pyro.module` on parameters loaded from
+           disk, be sure to set the ``update_module_params`` flag::
+
+               pyro.get_param_store().load('saved_params.save')
+               pyro.module('module', nn, update_module_params=True)
+
         :param filename: file name to load from
         :type name: str
         """

{"golden_diff": "diff --git a/pyro/params/param_store.py b/pyro/params/param_store.py\n--- a/pyro/params/param_store.py\n+++ b/pyro/params/param_store.py\n@@ -174,6 +174,14 @@\n         \"\"\"\n         Loads parameters from disk\n \n+        .. note::\n+\n+           If using :meth:`pyro.module` on parameters loaded from\n+           disk, be sure to set the ``update_module_params`` flag::\n+\n+               pyro.get_param_store().load('saved_params.save')\n+               pyro.module('module', nn, update_module_params=True)\n+\n         :param filename: file name to load from\n         :type name: str\n         \"\"\"\n", "issue": "Update paramstore documentation\nParams are not properly reused from the paramstore via `.load()` since the default flag `update_module_params` is false (iirc this is because of `random_module`).  the interface/defaults should be revisited and at the very least, documentation updated.\r\n\r\n[source](https://forum.pyro.ai/t/pyro-get-param-store-load-documentation/299)\n", "before_files": [{"content": "from __future__ import absolute_import, division, print_function\n\nimport weakref\n\nimport torch\nfrom torch.distributions import constraints, transform_to\n\n\nclass ParamStoreDict(object):\n    \"\"\"\n    Global store for parameters in Pyro. This is basically a key-value store.\n    The typical user interacts with the ParamStore primarily through the\n    primitive `pyro.param`.\n\n    See `Intro Part II <http://pyro.ai/examples/intro_part_ii.html>`_ for further discussion\n    and `SVI Part I <http://pyro.ai/examples/svi_part_i.html>`_ for some examples.\n\n    Some things to bear in mind when using parameters in Pyro:\n\n    - parameters must be assigned unique names\n    - the `init_tensor` argument to `pyro.param` is only used the first time that a given (named)\n      parameter is registered with Pyro.\n    - for this reason, a user may need to use the `clear()` method if working in a REPL in order to\n      get the desired behavior. this method can also be invoked with `pyro.clear_param_store()`.\n    - the internal name of a parameter within a PyTorch `nn.Module` that has been registered with\n      Pyro is prepended with the Pyro name of the module. so nothing prevents the user from having\n      two different modules each of which contains a parameter named `weight`. by contrast, a user\n      can only have one top-level parameter named `weight` (outside of any module).\n    - parameters can be saved and loaded from disk using `save` and `load`.\n    \"\"\"\n\n    def __init__(self):\n        \"\"\"\n        initialize ParamStore data structures\n        \"\"\"\n        self._params = {}  # dictionary from param name to param\n        self._param_to_name = {}  # dictionary from unconstrained param to param name\n        self._constraints = {}  # dictionary from param name to constraint object\n\n    def clear(self):\n        \"\"\"\n        Clear the ParamStore\n        \"\"\"\n        self._params = {}\n        self._param_to_name = {}\n        self._constraints = {}\n\n    def named_parameters(self):\n        \"\"\"\n        Returns an iterator over tuples of the form (name, parameter) for each parameter in the ParamStore\n        \"\"\"\n        # TODO consider returing constrained\n        return self._params.items()\n\n    def get_all_param_names(self):\n        \"\"\"\n        Get all parameter names in the ParamStore\n        \"\"\"\n        return self._params.keys()\n\n    def replace_param(self, param_name, new_param, old_param):\n        \"\"\"\n        Replace the param param_name with current value old_param with the new value new_param\n\n        :param param_name: parameter name\n        :type param_name: str\n        :param new_param: the paramater to be put into the ParamStore\n        :type new_param: torch.Tensor\n        :param old_param: the paramater to be removed from the ParamStore\n        :type new_param: torch.Tensor\n        \"\"\"\n        assert self._params[param_name] is old_param.unconstrained()\n        del self._params[param_name]\n        del self._param_to_name[old_param.unconstrained()]\n        self.get_param(param_name, new_param, constraint=self._constraints[param_name])\n\n    def get_param(self, name, init_tensor=None, constraint=constraints.real):\n        \"\"\"\n        Get parameter from its name. If it does not yet exist in the\n        ParamStore, it will be created and stored.\n        The Pyro primitive `pyro.param` dispatches to this method.\n\n        :param name: parameter name\n        :type name: str\n        :param init_tensor: initial tensor\n        :type init_tensor: torch.Tensor\n        :returns: parameter\n        :rtype: torch.Tensor\n        \"\"\"\n        if name not in self._params:\n            # if not create the init tensor through\n            assert init_tensor is not None,\\\n                \"cannot initialize a parameter '{}' with None. Did you get the param name right?\".format(name)\n\n            # a function\n            if callable(init_tensor):\n                init_tensor = init_tensor()\n\n            # store the unconstrained value and constraint\n            with torch.no_grad():\n                unconstrained_param = transform_to(constraint).inv(init_tensor)\n            unconstrained_param.requires_grad_(True)\n            self._params[name] = unconstrained_param\n            self._constraints[name] = constraint\n\n            # keep track of each tensor and it's name\n            self._param_to_name[unconstrained_param] = name\n\n        elif init_tensor is not None and not callable(init_tensor):\n            if self._params[name].shape != init_tensor.shape:\n                raise ValueError(\"param {} init tensor shape does not match existing value: {} vs {}\".format(\n                    name, init_tensor.shape, self._params[name].shape))\n\n        # get the guaranteed to exist param\n        unconstrained_param = self._params[name]\n\n        # compute the constrained value\n        param = transform_to(self._constraints[name])(unconstrained_param)\n        param.unconstrained = weakref.ref(unconstrained_param)\n\n        return param\n\n    def param_name(self, p):\n        \"\"\"\n        Get parameter name from parameter\n\n        :param p: parameter\n        :returns: parameter name\n        \"\"\"\n        if p not in self._param_to_name:\n            return None\n\n        return self._param_to_name[p]\n\n    def get_state(self):\n        \"\"\"\n        Get the ParamStore state.\n        \"\"\"\n        state = {\n            'params': self._params,\n            'constraints': self._constraints,\n        }\n        return state\n\n    def set_state(self, state):\n        \"\"\"\n        Set the ParamStore state using state from a previous get_state() call\n        \"\"\"\n        assert isinstance(state, dict), \"malformed ParamStore state\"\n        assert set(state.keys()) == set(['params', 'constraints']), \\\n            \"malformed ParamStore keys {}\".format(state.keys())\n\n        for param_name, param in state['params'].items():\n            self._params[param_name] = param\n            self._param_to_name[param] = param_name\n\n        for param_name, constraint in state['constraints'].items():\n            if isinstance(constraint, type(constraints.real)):\n                # Work around lack of hash & equality comparison on constraints.\n                constraint = constraints.real\n            self._constraints[param_name] = constraint\n\n    def save(self, filename):\n        \"\"\"\n        Save parameters to disk\n\n        :param filename: file name to save to\n        :type name: str\n        \"\"\"\n        with open(filename, \"wb\") as output_file:\n            torch.save(self.get_state(), output_file)\n\n    def load(self, filename):\n        \"\"\"\n        Loads parameters from disk\n\n        :param filename: file name to load from\n        :type name: str\n        \"\"\"\n        with open(filename, \"rb\") as input_file:\n            state = torch.load(input_file)\n        self.set_state(state)\n\n\n# used to create fully-formed param names, e.g. mymodule$$$mysubmodule.weight\n_MODULE_NAMESPACE_DIVIDER = \"$$$\"\n\n\ndef param_with_module_name(pyro_name, param_name):\n    return _MODULE_NAMESPACE_DIVIDER.join([pyro_name, param_name])\n\n\ndef module_from_param_with_module_name(param_name):\n    return param_name.split(_MODULE_NAMESPACE_DIVIDER)[0]\n\n\ndef user_param_name(param_name):\n    if _MODULE_NAMESPACE_DIVIDER in param_name:\n        return param_name.split(_MODULE_NAMESPACE_DIVIDER)[1]\n    return param_name\n", "path": "pyro/params/param_store.py"}], "after_files": [{"content": "from __future__ import absolute_import, division, print_function\n\nimport weakref\n\nimport torch\nfrom torch.distributions import constraints, transform_to\n\n\nclass ParamStoreDict(object):\n    \"\"\"\n    Global store for parameters in Pyro. This is basically a key-value store.\n    The typical user interacts with the ParamStore primarily through the\n    primitive `pyro.param`.\n\n    See `Intro Part II <http://pyro.ai/examples/intro_part_ii.html>`_ for further discussion\n    and `SVI Part I <http://pyro.ai/examples/svi_part_i.html>`_ for some examples.\n\n    Some things to bear in mind when using parameters in Pyro:\n\n    - parameters must be assigned unique names\n    - the `init_tensor` argument to `pyro.param` is only used the first time that a given (named)\n      parameter is registered with Pyro.\n    - for this reason, a user may need to use the `clear()` method if working in a REPL in order to\n      get the desired behavior. this method can also be invoked with `pyro.clear_param_store()`.\n    - the internal name of a parameter within a PyTorch `nn.Module` that has been registered with\n      Pyro is prepended with the Pyro name of the module. so nothing prevents the user from having\n      two different modules each of which contains a parameter named `weight`. by contrast, a user\n      can only have one top-level parameter named `weight` (outside of any module).\n    - parameters can be saved and loaded from disk using `save` and `load`.\n    \"\"\"\n\n    def __init__(self):\n        \"\"\"\n        initialize ParamStore data structures\n        \"\"\"\n        self._params = {}  # dictionary from param name to param\n        self._param_to_name = {}  # dictionary from unconstrained param to param name\n        self._constraints = {}  # dictionary from param name to constraint object\n\n    def clear(self):\n        \"\"\"\n        Clear the ParamStore\n        \"\"\"\n        self._params = {}\n        self._param_to_name = {}\n        self._constraints = {}\n\n    def named_parameters(self):\n        \"\"\"\n        Returns an iterator over tuples of the form (name, parameter) for each parameter in the ParamStore\n        \"\"\"\n        # TODO consider returing constrained\n        return self._params.items()\n\n    def get_all_param_names(self):\n        \"\"\"\n        Get all parameter names in the ParamStore\n        \"\"\"\n        return self._params.keys()\n\n    def replace_param(self, param_name, new_param, old_param):\n        \"\"\"\n        Replace the param param_name with current value old_param with the new value new_param\n\n        :param param_name: parameter name\n        :type param_name: str\n        :param new_param: the paramater to be put into the ParamStore\n        :type new_param: torch.Tensor\n        :param old_param: the paramater to be removed from the ParamStore\n        :type new_param: torch.Tensor\n        \"\"\"\n        assert self._params[param_name] is old_param.unconstrained()\n        del self._params[param_name]\n        del self._param_to_name[old_param.unconstrained()]\n        self.get_param(param_name, new_param, constraint=self._constraints[param_name])\n\n    def get_param(self, name, init_tensor=None, constraint=constraints.real):\n        \"\"\"\n        Get parameter from its name. If it does not yet exist in the\n        ParamStore, it will be created and stored.\n        The Pyro primitive `pyro.param` dispatches to this method.\n\n        :param name: parameter name\n        :type name: str\n        :param init_tensor: initial tensor\n        :type init_tensor: torch.Tensor\n        :returns: parameter\n        :rtype: torch.Tensor\n        \"\"\"\n        if name not in self._params:\n            # if not create the init tensor through\n            assert init_tensor is not None,\\\n                \"cannot initialize a parameter '{}' with None. Did you get the param name right?\".format(name)\n\n            # a function\n            if callable(init_tensor):\n                init_tensor = init_tensor()\n\n            # store the unconstrained value and constraint\n            with torch.no_grad():\n                unconstrained_param = transform_to(constraint).inv(init_tensor)\n            unconstrained_param.requires_grad_(True)\n            self._params[name] = unconstrained_param\n            self._constraints[name] = constraint\n\n            # keep track of each tensor and it's name\n            self._param_to_name[unconstrained_param] = name\n\n        elif init_tensor is not None and not callable(init_tensor):\n            if self._params[name].shape != init_tensor.shape:\n                raise ValueError(\"param {} init tensor shape does not match existing value: {} vs {}\".format(\n                    name, init_tensor.shape, self._params[name].shape))\n\n        # get the guaranteed to exist param\n        unconstrained_param = self._params[name]\n\n        # compute the constrained value\n        param = transform_to(self._constraints[name])(unconstrained_param)\n        param.unconstrained = weakref.ref(unconstrained_param)\n\n        return param\n\n    def param_name(self, p):\n        \"\"\"\n        Get parameter name from parameter\n\n        :param p: parameter\n        :returns: parameter name\n        \"\"\"\n        if p not in self._param_to_name:\n            return None\n\n        return self._param_to_name[p]\n\n    def get_state(self):\n        \"\"\"\n        Get the ParamStore state.\n        \"\"\"\n        state = {\n            'params': self._params,\n            'constraints': self._constraints,\n        }\n        return state\n\n    def set_state(self, state):\n        \"\"\"\n        Set the ParamStore state using state from a previous get_state() call\n        \"\"\"\n        assert isinstance(state, dict), \"malformed ParamStore state\"\n        assert set(state.keys()) == set(['params', 'constraints']), \\\n            \"malformed ParamStore keys {}\".format(state.keys())\n\n        for param_name, param in state['params'].items():\n            self._params[param_name] = param\n            self._param_to_name[param] = param_name\n\n        for param_name, constraint in state['constraints'].items():\n            if isinstance(constraint, type(constraints.real)):\n                # Work around lack of hash & equality comparison on constraints.\n                constraint = constraints.real\n            self._constraints[param_name] = constraint\n\n    def save(self, filename):\n        \"\"\"\n        Save parameters to disk\n\n        :param filename: file name to save to\n        :type name: str\n        \"\"\"\n        with open(filename, \"wb\") as output_file:\n            torch.save(self.get_state(), output_file)\n\n    def load(self, filename):\n        \"\"\"\n        Loads parameters from disk\n\n        .. note::\n\n           If using :meth:`pyro.module` on parameters loaded from\n           disk, be sure to set the ``update_module_params`` flag::\n\n               pyro.get_param_store().load('saved_params.save')\n               pyro.module('module', nn, update_module_params=True)\n\n        :param filename: file name to load from\n        :type name: str\n        \"\"\"\n        with open(filename, \"rb\") as input_file:\n            state = torch.load(input_file)\n        self.set_state(state)\n\n\n# used to create fully-formed param names, e.g. mymodule$$$mysubmodule.weight\n_MODULE_NAMESPACE_DIVIDER = \"$$$\"\n\n\ndef param_with_module_name(pyro_name, param_name):\n    return _MODULE_NAMESPACE_DIVIDER.join([pyro_name, param_name])\n\n\ndef module_from_param_with_module_name(param_name):\n    return param_name.split(_MODULE_NAMESPACE_DIVIDER)[0]\n\n\ndef user_param_name(param_name):\n    if _MODULE_NAMESPACE_DIVIDER in param_name:\n        return param_name.split(_MODULE_NAMESPACE_DIVIDER)[1]\n    return param_name\n", "path": "pyro/params/param_store.py"}]}