We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Test batch_size parameter is correctly applied for all distributions
With #323, we are now supporting `batch_size` parameter for both the class and functional forms of both the distributions. Let us add a simple test to validate that this is working as expected. 

--- 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/distributions/log_normal.py`
Content:
```
1 import numpy as np
2 import torch
3 from torch.autograd import Variable
4 
5 from pyro.distributions.distribution import Distribution
6 
7 
8 class LogNormal(Distribution):
9     """
10     :param mu: mean *(vector)*
11     :param sigma: standard deviations *(vector (0, Infinity))*
12 
13     A distribution over probability vectors obtained by exp-transforming a random
14     variable drawn from ``Normal({mu: mu, sigma: sigma})``.
15     """
16     reparameterized = True
17 
18     def __init__(self, mu, sigma, batch_size=None, *args, **kwargs):
19         """
20         Params:
21           `mu` - mean
22           `sigma` - root variance
23         """
24         self.mu = mu
25         self.sigma = sigma
26         if mu.size() != sigma.size():
27             raise ValueError("Expected mu.size() == sigma.size(), but got {} vs {}"
28                              .format(mu.size(), sigma.size()))
29         if mu.dim() == 1 and batch_size is not None:
30             self.mu = mu.expand(batch_size, mu.size(0))
31             self.sigma = sigma.expand(batch_size, sigma.size(0))
32         super(LogNormal, self).__init__(*args, **kwargs)
33 
34     def batch_shape(self, x=None):
35         event_dim = 1
36         mu = self.mu
37         if x is not None and x.size() != mu.size():
38             mu = self.mu.expand(x.size()[:-event_dim] + self.event_shape())
39         return mu.size()[:-event_dim]
40 
41     def event_shape(self):
42         event_dim = 1
43         return self.mu.size()[-event_dim:]
44 
45     def shape(self, x=None):
46         return self.batch_shape(x) + self.event_shape()
47 
48     def sample(self):
49         """
50         Reparameterized log-normal sampler.
51         """
52         eps = Variable(torch.randn(1).type_as(self.mu.data))
53         z = self.mu + self.sigma * eps
54         return torch.exp(z)
55 
56     def batch_log_pdf(self, x):
57         """
58         log-normal log-likelihood
59         """
60         mu = self.mu.expand(self.shape(x))
61         sigma = self.sigma.expand(self.shape(x))
62         ll_1 = Variable(torch.Tensor([-0.5 * np.log(2.0 * np.pi)])
63                         .type_as(mu.data).expand_as(x))
64         ll_2 = -torch.log(sigma * x)
65         ll_3 = -0.5 * torch.pow((torch.log(x) - mu) / sigma, 2.0)
66         batch_log_pdf = torch.sum(ll_1 + ll_2 + ll_3, -1)
67         batch_log_pdf_shape = self.batch_shape(x) + (1,)
68         return batch_log_pdf.contiguous().view(batch_log_pdf_shape)
69 
70     def analytic_mean(self):
71         return torch.exp(self.mu + 0.5 * torch.pow(self.sigma, 2.0))
72 
73     def analytic_var(self):
74         return (torch.exp(torch.pow(self.sigma, 2.0)) - Variable(torch.ones(1))) * \
75             torch.pow(self.analytic_mean(), 2)
76
```
--- 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/distributions/log_normal.py b/pyro/distributions/log_normal.py
--- a/pyro/distributions/log_normal.py
+++ b/pyro/distributions/log_normal.py
@@ -49,7 +49,7 @@
         """
         Reparameterized log-normal sampler.
         """
-        eps = Variable(torch.randn(1).type_as(self.mu.data))
+        eps = Variable(torch.randn(self.mu.size()).type_as(self.mu.data))
         z = self.mu + self.sigma * eps
         return torch.exp(z)

{"golden_diff": "diff --git a/pyro/distributions/log_normal.py b/pyro/distributions/log_normal.py\n--- a/pyro/distributions/log_normal.py\n+++ b/pyro/distributions/log_normal.py\n@@ -49,7 +49,7 @@\n         \"\"\"\n         Reparameterized log-normal sampler.\n         \"\"\"\n-        eps = Variable(torch.randn(1).type_as(self.mu.data))\n+        eps = Variable(torch.randn(self.mu.size()).type_as(self.mu.data))\n         z = self.mu + self.sigma * eps\n         return torch.exp(z)\n", "issue": "Test batch_size parameter is correctly applied for all distributions\nWith #323, we are now supporting `batch_size` parameter for both the class and functional forms of both the distributions. Let us add a simple test to validate that this is working as expected. \n", "before_files": [{"content": "import numpy as np\nimport torch\nfrom torch.autograd import Variable\n\nfrom pyro.distributions.distribution import Distribution\n\n\nclass LogNormal(Distribution):\n    \"\"\"\n    :param mu: mean *(vector)*\n    :param sigma: standard deviations *(vector (0, Infinity))*\n\n    A distribution over probability vectors obtained by exp-transforming a random\n    variable drawn from ``Normal({mu: mu, sigma: sigma})``.\n    \"\"\"\n    reparameterized = True\n\n    def __init__(self, mu, sigma, batch_size=None, *args, **kwargs):\n        \"\"\"\n        Params:\n          `mu` - mean\n          `sigma` - root variance\n        \"\"\"\n        self.mu = mu\n        self.sigma = sigma\n        if mu.size() != sigma.size():\n            raise ValueError(\"Expected mu.size() == sigma.size(), but got {} vs {}\"\n                             .format(mu.size(), sigma.size()))\n        if mu.dim() == 1 and batch_size is not None:\n            self.mu = mu.expand(batch_size, mu.size(0))\n            self.sigma = sigma.expand(batch_size, sigma.size(0))\n        super(LogNormal, self).__init__(*args, **kwargs)\n\n    def batch_shape(self, x=None):\n        event_dim = 1\n        mu = self.mu\n        if x is not None and x.size() != mu.size():\n            mu = self.mu.expand(x.size()[:-event_dim] + self.event_shape())\n        return mu.size()[:-event_dim]\n\n    def event_shape(self):\n        event_dim = 1\n        return self.mu.size()[-event_dim:]\n\n    def shape(self, x=None):\n        return self.batch_shape(x) + self.event_shape()\n\n    def sample(self):\n        \"\"\"\n        Reparameterized log-normal sampler.\n        \"\"\"\n        eps = Variable(torch.randn(1).type_as(self.mu.data))\n        z = self.mu + self.sigma * eps\n        return torch.exp(z)\n\n    def batch_log_pdf(self, x):\n        \"\"\"\n        log-normal log-likelihood\n        \"\"\"\n        mu = self.mu.expand(self.shape(x))\n        sigma = self.sigma.expand(self.shape(x))\n        ll_1 = Variable(torch.Tensor([-0.5 * np.log(2.0 * np.pi)])\n                        .type_as(mu.data).expand_as(x))\n        ll_2 = -torch.log(sigma * x)\n        ll_3 = -0.5 * torch.pow((torch.log(x) - mu) / sigma, 2.0)\n        batch_log_pdf = torch.sum(ll_1 + ll_2 + ll_3, -1)\n        batch_log_pdf_shape = self.batch_shape(x) + (1,)\n        return batch_log_pdf.contiguous().view(batch_log_pdf_shape)\n\n    def analytic_mean(self):\n        return torch.exp(self.mu + 0.5 * torch.pow(self.sigma, 2.0))\n\n    def analytic_var(self):\n        return (torch.exp(torch.pow(self.sigma, 2.0)) - Variable(torch.ones(1))) * \\\n            torch.pow(self.analytic_mean(), 2)\n", "path": "pyro/distributions/log_normal.py"}], "after_files": [{"content": "import numpy as np\nimport torch\nfrom torch.autograd import Variable\n\nfrom pyro.distributions.distribution import Distribution\n\n\nclass LogNormal(Distribution):\n    \"\"\"\n    :param mu: mean *(vector)*\n    :param sigma: standard deviations *(vector (0, Infinity))*\n\n    A distribution over probability vectors obtained by exp-transforming a random\n    variable drawn from ``Normal({mu: mu, sigma: sigma})``.\n    \"\"\"\n    reparameterized = True\n\n    def __init__(self, mu, sigma, batch_size=None, *args, **kwargs):\n        \"\"\"\n        Params:\n          `mu` - mean\n          `sigma` - root variance\n        \"\"\"\n        self.mu = mu\n        self.sigma = sigma\n        if mu.size() != sigma.size():\n            raise ValueError(\"Expected mu.size() == sigma.size(), but got {} vs {}\"\n                             .format(mu.size(), sigma.size()))\n        if mu.dim() == 1 and batch_size is not None:\n            self.mu = mu.expand(batch_size, mu.size(0))\n            self.sigma = sigma.expand(batch_size, sigma.size(0))\n        super(LogNormal, self).__init__(*args, **kwargs)\n\n    def batch_shape(self, x=None):\n        event_dim = 1\n        mu = self.mu\n        if x is not None and x.size() != mu.size():\n            mu = self.mu.expand(x.size()[:-event_dim] + self.event_shape())\n        return mu.size()[:-event_dim]\n\n    def event_shape(self):\n        event_dim = 1\n        return self.mu.size()[-event_dim:]\n\n    def shape(self, x=None):\n        return self.batch_shape(x) + self.event_shape()\n\n    def sample(self):\n        \"\"\"\n        Reparameterized log-normal sampler.\n        \"\"\"\n        eps = Variable(torch.randn(self.mu.size()).type_as(self.mu.data))\n        z = self.mu + self.sigma * eps\n        return torch.exp(z)\n\n    def batch_log_pdf(self, x):\n        \"\"\"\n        log-normal log-likelihood\n        \"\"\"\n        mu = self.mu.expand(self.shape(x))\n        sigma = self.sigma.expand(self.shape(x))\n        ll_1 = Variable(torch.Tensor([-0.5 * np.log(2.0 * np.pi)])\n                        .type_as(mu.data).expand_as(x))\n        ll_2 = -torch.log(sigma * x)\n        ll_3 = -0.5 * torch.pow((torch.log(x) - mu) / sigma, 2.0)\n        batch_log_pdf = torch.sum(ll_1 + ll_2 + ll_3, -1)\n        batch_log_pdf_shape = self.batch_shape(x) + (1,)\n        return batch_log_pdf.contiguous().view(batch_log_pdf_shape)\n\n    def analytic_mean(self):\n        return torch.exp(self.mu + 0.5 * torch.pow(self.sigma, 2.0))\n\n    def analytic_var(self):\n        return (torch.exp(torch.pow(self.sigma, 2.0)) - Variable(torch.ones(1))) * \\\n            torch.pow(self.analytic_mean(), 2)\n", "path": "pyro/distributions/log_normal.py"}]}