prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <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. 
  
  </issue>
  <code>
  [start of pyro/distributions/log_normal.py]
  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 of pyro/distributions/log_normal.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: 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)
  
verification_info: {"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"}]}