We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[Bug] Cannot serialize/deserialize SmoothedBoxPrior when some args are broadcast
# 🐛 Bug

It seems like `SmoothedBoxPrior` for >1d doesn't work with serialization/deserialization when only some args are broadcast. 

## To reproduce

```python
import torch
import gpytorch
pr = gpytorch.priors.SmoothedBoxPrior(torch.zeros(2), torch.ones(2))
pr.load_state_dict(pr.state_dict())
```

** Stack trace/error message **
```
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-5-6b4b2e881beb> in <module>
      2 import gpytorch
      3 pr = gpytorch.priors.SmoothedBoxPrior(torch.zeros(2), torch.ones(2))
----> 4 pr.load_state_dict(pr.state_dict())

<...PATH..>/torch/nn/modules/module.py in load_state_dict(self, state_dict, strict)
    877         if len(error_msgs) > 0:
    878             raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
--> 879                                self.__class__.__name__, "\n\t".join(error_msgs)))
    880         return _IncompatibleKeys(missing_keys, unexpected_keys)
    881 

RuntimeError: Error(s) in loading state_dict for SmoothedBoxPrior:
	While copying the parameter named "sigma", whose dimensions in the model are torch.Size([2]) and whose dimensions in the checkpoint are torch.Size([2]), an exception occured : ('unsupported operation: more than one element of the written-to tensor refers to a single memory location. Please clone() the tensor before performing the operation.',).

```

Note that `SmoothedBoxPrior(a=torch.zeros(2), b=torch.ones(2), sigma=torch.ones(2)*0.01)` succeeds, as does `gpytorch.priors.GammaPrior(torch.ones(2),1)`.

## Expected Behavior

Successful load. 

## System information

**Please complete the following information:**
- gpytorch version: 1.1.1
- pytorch version: 1.5.0
- OS: tested on Centos and Mac OSX. 




--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `gpytorch/priors/smoothed_box_prior.py`
Content:
```
1 #!/usr/bin/env python3
2 
3 import math
4 from numbers import Number
5 
6 import torch
7 from torch.distributions import constraints
8 from torch.distributions.utils import broadcast_all
9 from torch.nn import Module as TModule
10 
11 from .prior import Prior
12 from .torch_priors import NormalPrior
13 
14 
15 class SmoothedBoxPrior(Prior):
16     r"""A smoothed approximation of a uniform prior.
17 
18     Has full support on the reals and is differentiable everywhere.
19 
20     .. math::
21 
22         \begin{equation*}
23             B = {x: a_i <= x_i <= b_i}
24             d(x, B) = min_{x' in B} |x - x'|
25             pdf(x) ~ exp(- d(x, B)**2 / sqrt(2 * sigma^2))
26         \end{equation*}
27 
28     """
29 
30     arg_constraints = {"sigma": constraints.positive, "a": constraints.real, "b": constraints.real}
31     support = constraints.real
32     _validate_args = True
33 
34     def __init__(self, a, b, sigma=0.01, validate_args=False, transform=None):
35         TModule.__init__(self)
36         _a = torch.tensor(float(a)) if isinstance(a, Number) else a
37         _a = _a.view(-1) if _a.dim() < 1 else _a
38         _a, _b, _sigma = broadcast_all(_a, b, sigma)
39         if not torch.all(constraints.less_than(_b).check(_a)):
40             raise ValueError("must have that a < b (element-wise)")
41         # TODO: Proper argument validation including broadcasting
42         batch_shape, event_shape = _a.shape[:-1], _a.shape[-1:]
43         # need to assign values before registering as buffers to make argument validation work
44         self.a, self.b, self.sigma = _a, _b, _sigma
45         super(SmoothedBoxPrior, self).__init__(batch_shape, event_shape, validate_args=validate_args)
46         # now need to delete to be able to register buffer
47         del self.a, self.b, self.sigma
48         self.register_buffer("a", _a)
49         self.register_buffer("b", _b)
50         self.register_buffer("sigma", _sigma)
51         self.tails = NormalPrior(torch.zeros_like(_a), _sigma, validate_args=validate_args)
52         self._transform = transform
53 
54     @property
55     def _c(self):
56         return (self.a + self.b) / 2
57 
58     @property
59     def _r(self):
60         return (self.b - self.a) / 2
61 
62     @property
63     def _M(self):
64         # normalization factor to make this a probability distribution
65         return torch.log(1 + (self.b - self.a) / (math.sqrt(2 * math.pi) * self.sigma))
66 
67     def log_prob(self, x):
68         return self._log_prob(self.transform(x))
69 
70     def _log_prob(self, x):
71         # x = "distances from box`"
72         X = ((x - self._c).abs_() - self._r).clamp(min=0)
73         return (self.tails.log_prob(X) - self._M).sum(-1)
74
```
--- 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/gpytorch/priors/smoothed_box_prior.py b/gpytorch/priors/smoothed_box_prior.py
--- a/gpytorch/priors/smoothed_box_prior.py
+++ b/gpytorch/priors/smoothed_box_prior.py
@@ -47,7 +47,7 @@
         del self.a, self.b, self.sigma
         self.register_buffer("a", _a)
         self.register_buffer("b", _b)
-        self.register_buffer("sigma", _sigma)
+        self.register_buffer("sigma", _sigma.clone())
         self.tails = NormalPrior(torch.zeros_like(_a), _sigma, validate_args=validate_args)
         self._transform = transform

{"golden_diff": "diff --git a/gpytorch/priors/smoothed_box_prior.py b/gpytorch/priors/smoothed_box_prior.py\n--- a/gpytorch/priors/smoothed_box_prior.py\n+++ b/gpytorch/priors/smoothed_box_prior.py\n@@ -47,7 +47,7 @@\n         del self.a, self.b, self.sigma\n         self.register_buffer(\"a\", _a)\n         self.register_buffer(\"b\", _b)\n-        self.register_buffer(\"sigma\", _sigma)\n+        self.register_buffer(\"sigma\", _sigma.clone())\n         self.tails = NormalPrior(torch.zeros_like(_a), _sigma, validate_args=validate_args)\n         self._transform = transform\n", "issue": "[Bug] Cannot serialize/deserialize SmoothedBoxPrior when some args are broadcast\n# \ud83d\udc1b Bug\r\n\r\nIt seems like `SmoothedBoxPrior` for >1d doesn't work with serialization/deserialization when only some args are broadcast. \r\n\r\n## To reproduce\r\n\r\n```python\r\nimport torch\r\nimport gpytorch\r\npr = gpytorch.priors.SmoothedBoxPrior(torch.zeros(2), torch.ones(2))\r\npr.load_state_dict(pr.state_dict())\r\n```\r\n\r\n** Stack trace/error message **\r\n```\r\n---------------------------------------------------------------------------\r\nRuntimeError                              Traceback (most recent call last)\r\n<ipython-input-5-6b4b2e881beb> in <module>\r\n      2 import gpytorch\r\n      3 pr = gpytorch.priors.SmoothedBoxPrior(torch.zeros(2), torch.ones(2))\r\n----> 4 pr.load_state_dict(pr.state_dict())\r\n\r\n<...PATH..>/torch/nn/modules/module.py in load_state_dict(self, state_dict, strict)\r\n    877         if len(error_msgs) > 0:\r\n    878             raise RuntimeError('Error(s) in loading state_dict for {}:\\n\\t{}'.format(\r\n--> 879                                self.__class__.__name__, \"\\n\\t\".join(error_msgs)))\r\n    880         return _IncompatibleKeys(missing_keys, unexpected_keys)\r\n    881 \r\n\r\nRuntimeError: Error(s) in loading state_dict for SmoothedBoxPrior:\r\n\tWhile copying the parameter named \"sigma\", whose dimensions in the model are torch.Size([2]) and whose dimensions in the checkpoint are torch.Size([2]), an exception occured : ('unsupported operation: more than one element of the written-to tensor refers to a single memory location. Please clone() the tensor before performing the operation.',).\r\n\r\n```\r\n\r\nNote that `SmoothedBoxPrior(a=torch.zeros(2), b=torch.ones(2), sigma=torch.ones(2)*0.01)` succeeds, as does `gpytorch.priors.GammaPrior(torch.ones(2),1)`.\r\n\r\n## Expected Behavior\r\n\r\nSuccessful load. \r\n\r\n## System information\r\n\r\n**Please complete the following information:**\r\n- gpytorch version: 1.1.1\r\n- pytorch version: 1.5.0\r\n- OS: tested on Centos and Mac OSX. \r\n\r\n\r\n\n", "before_files": [{"content": "#!/usr/bin/env python3\n\nimport math\nfrom numbers import Number\n\nimport torch\nfrom torch.distributions import constraints\nfrom torch.distributions.utils import broadcast_all\nfrom torch.nn import Module as TModule\n\nfrom .prior import Prior\nfrom .torch_priors import NormalPrior\n\n\nclass SmoothedBoxPrior(Prior):\n    r\"\"\"A smoothed approximation of a uniform prior.\n\n    Has full support on the reals and is differentiable everywhere.\n\n    .. math::\n\n        \\begin{equation*}\n            B = {x: a_i <= x_i <= b_i}\n            d(x, B) = min_{x' in B} |x - x'|\n            pdf(x) ~ exp(- d(x, B)**2 / sqrt(2 * sigma^2))\n        \\end{equation*}\n\n    \"\"\"\n\n    arg_constraints = {\"sigma\": constraints.positive, \"a\": constraints.real, \"b\": constraints.real}\n    support = constraints.real\n    _validate_args = True\n\n    def __init__(self, a, b, sigma=0.01, validate_args=False, transform=None):\n        TModule.__init__(self)\n        _a = torch.tensor(float(a)) if isinstance(a, Number) else a\n        _a = _a.view(-1) if _a.dim() < 1 else _a\n        _a, _b, _sigma = broadcast_all(_a, b, sigma)\n        if not torch.all(constraints.less_than(_b).check(_a)):\n            raise ValueError(\"must have that a < b (element-wise)\")\n        # TODO: Proper argument validation including broadcasting\n        batch_shape, event_shape = _a.shape[:-1], _a.shape[-1:]\n        # need to assign values before registering as buffers to make argument validation work\n        self.a, self.b, self.sigma = _a, _b, _sigma\n        super(SmoothedBoxPrior, self).__init__(batch_shape, event_shape, validate_args=validate_args)\n        # now need to delete to be able to register buffer\n        del self.a, self.b, self.sigma\n        self.register_buffer(\"a\", _a)\n        self.register_buffer(\"b\", _b)\n        self.register_buffer(\"sigma\", _sigma)\n        self.tails = NormalPrior(torch.zeros_like(_a), _sigma, validate_args=validate_args)\n        self._transform = transform\n\n    @property\n    def _c(self):\n        return (self.a + self.b) / 2\n\n    @property\n    def _r(self):\n        return (self.b - self.a) / 2\n\n    @property\n    def _M(self):\n        # normalization factor to make this a probability distribution\n        return torch.log(1 + (self.b - self.a) / (math.sqrt(2 * math.pi) * self.sigma))\n\n    def log_prob(self, x):\n        return self._log_prob(self.transform(x))\n\n    def _log_prob(self, x):\n        # x = \"distances from box`\"\n        X = ((x - self._c).abs_() - self._r).clamp(min=0)\n        return (self.tails.log_prob(X) - self._M).sum(-1)\n", "path": "gpytorch/priors/smoothed_box_prior.py"}], "after_files": [{"content": "#!/usr/bin/env python3\n\nimport math\nfrom numbers import Number\n\nimport torch\nfrom torch.distributions import constraints\nfrom torch.distributions.utils import broadcast_all\nfrom torch.nn import Module as TModule\n\nfrom .prior import Prior\nfrom .torch_priors import NormalPrior\n\n\nclass SmoothedBoxPrior(Prior):\n    r\"\"\"A smoothed approximation of a uniform prior.\n\n    Has full support on the reals and is differentiable everywhere.\n\n    .. math::\n\n        \\begin{equation*}\n            B = {x: a_i <= x_i <= b_i}\n            d(x, B) = min_{x' in B} |x - x'|\n            pdf(x) ~ exp(- d(x, B)**2 / sqrt(2 * sigma^2))\n        \\end{equation*}\n\n    \"\"\"\n\n    arg_constraints = {\"sigma\": constraints.positive, \"a\": constraints.real, \"b\": constraints.real}\n    support = constraints.real\n    _validate_args = True\n\n    def __init__(self, a, b, sigma=0.01, validate_args=False, transform=None):\n        TModule.__init__(self)\n        _a = torch.tensor(float(a)) if isinstance(a, Number) else a\n        _a = _a.view(-1) if _a.dim() < 1 else _a\n        _a, _b, _sigma = broadcast_all(_a, b, sigma)\n        if not torch.all(constraints.less_than(_b).check(_a)):\n            raise ValueError(\"must have that a < b (element-wise)\")\n        # TODO: Proper argument validation including broadcasting\n        batch_shape, event_shape = _a.shape[:-1], _a.shape[-1:]\n        # need to assign values before registering as buffers to make argument validation work\n        self.a, self.b, self.sigma = _a, _b, _sigma\n        super(SmoothedBoxPrior, self).__init__(batch_shape, event_shape, validate_args=validate_args)\n        # now need to delete to be able to register buffer\n        del self.a, self.b, self.sigma\n        self.register_buffer(\"a\", _a)\n        self.register_buffer(\"b\", _b)\n        self.register_buffer(\"sigma\", _sigma.clone())\n        self.tails = NormalPrior(torch.zeros_like(_a), _sigma, validate_args=validate_args)\n        self._transform = transform\n\n    @property\n    def _c(self):\n        return (self.a + self.b) / 2\n\n    @property\n    def _r(self):\n        return (self.b - self.a) / 2\n\n    @property\n    def _M(self):\n        # normalization factor to make this a probability distribution\n        return torch.log(1 + (self.b - self.a) / (math.sqrt(2 * math.pi) * self.sigma))\n\n    def log_prob(self, x):\n        return self._log_prob(self.transform(x))\n\n    def _log_prob(self, x):\n        # x = \"distances from box`\"\n        X = ((x - self._c).abs_() - self._r).clamp(min=0)\n        return (self.tails.log_prob(X) - self._M).sum(-1)\n", "path": "gpytorch/priors/smoothed_box_prior.py"}]}