prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Fix segmentation example
  # Before submitting
  
  - [x] Was this discussed/approved via a Github issue? (no need for typos, doc improvements)
  - [x] Did you read the [contributor guideline](https://github.com/PyTorchLightning/pytorch-lightning/blob/master/.github/CONTRIBUTING.md)?
  - [x] Did you make sure to update the docs?   
  - [ ] Did you write any new necessary tests?  
  
  ## What does this PR do?
  Fixes #874 (issue).
  
  ## PR review    
  Anyone in the community is free to review the PR once the tests have passed. 
  
  ## Some comments
  I have added a custom model (UNet) instead of the previous torchvision segmentation model as it was causing tests to fail (mostly because those torchvision models were introduced in version 0.3 and it will fail for previous versions).
  
  </issue>
  <code>
  [start of pl_examples/full_examples/semantic_segmentation/models/unet/model.py]
  1 import torch
  2 import torch.nn as nn
  3 import torch.nn.functional as F
  4 
  5 from parts import DoubleConv, Down, Up
  6 
  7 
  8 class UNet(nn.Module):
  9     '''
  10     Architecture based on U-Net: Convolutional Networks for Biomedical Image Segmentation
  11     Link - https://arxiv.org/abs/1505.04597
  12     '''
  13     def __init__(self, num_classes=19, bilinear=False):
  14         super().__init__()
  15         self.bilinear = bilinear
  16         self.num_classes = num_classes
  17         self.layer1 = DoubleConv(3, 64)
  18         self.layer2 = Down(64, 128)
  19         self.layer3 = Down(128, 256)
  20         self.layer4 = Down(256, 512)
  21         self.layer5 = Down(512, 1024)
  22 
  23         self.layer6 = Up(1024, 512, bilinear=self.bilinear)
  24         self.layer7 = Up(512, 256, bilinear=self.bilinear)
  25         self.layer8 = Up(256, 128, bilinear=self.bilinear)
  26         self.layer9 = Up(128, 64, bilinear=self.bilinear)
  27 
  28         self.layer10 = nn.Conv2d(64, self.num_classes, kernel_size=1)
  29 
  30     def forward(self, x):
  31         x1 = self.layer1(x)
  32         x2 = self.layer2(x1)
  33         x3 = self.layer3(x2)
  34         x4 = self.layer4(x3)
  35         x5 = self.layer5(x4)
  36 
  37         x6 = self.layer6(x5, x4)
  38         x6 = self.layer7(x6, x3)
  39         x6 = self.layer8(x6, x2)
  40         x6 = self.layer9(x6, x1)
  41 
  42         return self.layer10(x6)
  43
  [end of pl_examples/full_examples/semantic_segmentation/models/unet/model.py]
  [start of pl_examples/full_examples/semantic_segmentation/models/unet/__init__.py]
  1 # For relative imports to work in Python 3.6
  2 import os
  3 import sys
  4 sys.path.append(os.path.dirname(os.path.realpath(__file__)))
  5
  [end of pl_examples/full_examples/semantic_segmentation/models/unet/__init__.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/pl_examples/full_examples/semantic_segmentation/models/unet/__init__.py b/pl_examples/full_examples/semantic_segmentation/models/unet/__init__.py
  deleted file mode 100644
  --- a/pl_examples/full_examples/semantic_segmentation/models/unet/__init__.py
  +++ /dev/null
  @@ -1,4 +0,0 @@
  -# For relative imports to work in Python 3.6
  -import os
  -import sys
  -sys.path.append(os.path.dirname(os.path.realpath(__file__)))
  diff --git a/pl_examples/full_examples/semantic_segmentation/models/unet/model.py b/pl_examples/full_examples/semantic_segmentation/models/unet/model.py
  --- a/pl_examples/full_examples/semantic_segmentation/models/unet/model.py
  +++ b/pl_examples/full_examples/semantic_segmentation/models/unet/model.py
  @@ -2,30 +2,33 @@
   import torch.nn as nn
   import torch.nn.functional as F
   
  -from parts import DoubleConv, Down, Up
  +from models.unet.parts import DoubleConv, Down, Up
   
   
   class UNet(nn.Module):
       '''
       Architecture based on U-Net: Convolutional Networks for Biomedical Image Segmentation
       Link - https://arxiv.org/abs/1505.04597
  +
  +    Parameters:
  +    num_classes (int) - Number of output classes required (default 19 for KITTI dataset)
  +    bilinear (bool) - Whether to use bilinear interpolation or transposed
  +    convolutions for upsampling.
       '''
       def __init__(self, num_classes=19, bilinear=False):
           super().__init__()
  -        self.bilinear = bilinear
  -        self.num_classes = num_classes
           self.layer1 = DoubleConv(3, 64)
           self.layer2 = Down(64, 128)
           self.layer3 = Down(128, 256)
           self.layer4 = Down(256, 512)
           self.layer5 = Down(512, 1024)
   
  -        self.layer6 = Up(1024, 512, bilinear=self.bilinear)
  -        self.layer7 = Up(512, 256, bilinear=self.bilinear)
  -        self.layer8 = Up(256, 128, bilinear=self.bilinear)
  -        self.layer9 = Up(128, 64, bilinear=self.bilinear)
  +        self.layer6 = Up(1024, 512, bilinear=bilinear)
  +        self.layer7 = Up(512, 256, bilinear=bilinear)
  +        self.layer8 = Up(256, 128, bilinear=bilinear)
  +        self.layer9 = Up(128, 64, bilinear=bilinear)
   
  -        self.layer10 = nn.Conv2d(64, self.num_classes, kernel_size=1)
  +        self.layer10 = nn.Conv2d(64, num_classes, kernel_size=1)
   
       def forward(self, x):
           x1 = self.layer1(x)
  
verification_info: {"golden_diff": "diff --git a/pl_examples/full_examples/semantic_segmentation/models/unet/__init__.py b/pl_examples/full_examples/semantic_segmentation/models/unet/__init__.py\ndeleted file mode 100644\n--- a/pl_examples/full_examples/semantic_segmentation/models/unet/__init__.py\n+++ /dev/null\n@@ -1,4 +0,0 @@\n-# For relative imports to work in Python 3.6\n-import os\n-import sys\n-sys.path.append(os.path.dirname(os.path.realpath(__file__)))\ndiff --git a/pl_examples/full_examples/semantic_segmentation/models/unet/model.py b/pl_examples/full_examples/semantic_segmentation/models/unet/model.py\n--- a/pl_examples/full_examples/semantic_segmentation/models/unet/model.py\n+++ b/pl_examples/full_examples/semantic_segmentation/models/unet/model.py\n@@ -2,30 +2,33 @@\n import torch.nn as nn\n import torch.nn.functional as F\n \n-from parts import DoubleConv, Down, Up\n+from models.unet.parts import DoubleConv, Down, Up\n \n \n class UNet(nn.Module):\n     '''\n     Architecture based on U-Net: Convolutional Networks for Biomedical Image Segmentation\n     Link - https://arxiv.org/abs/1505.04597\n+\n+    Parameters:\n+    num_classes (int) - Number of output classes required (default 19 for KITTI dataset)\n+    bilinear (bool) - Whether to use bilinear interpolation or transposed\n+    convolutions for upsampling.\n     '''\n     def __init__(self, num_classes=19, bilinear=False):\n         super().__init__()\n-        self.bilinear = bilinear\n-        self.num_classes = num_classes\n         self.layer1 = DoubleConv(3, 64)\n         self.layer2 = Down(64, 128)\n         self.layer3 = Down(128, 256)\n         self.layer4 = Down(256, 512)\n         self.layer5 = Down(512, 1024)\n \n-        self.layer6 = Up(1024, 512, bilinear=self.bilinear)\n-        self.layer7 = Up(512, 256, bilinear=self.bilinear)\n-        self.layer8 = Up(256, 128, bilinear=self.bilinear)\n-        self.layer9 = Up(128, 64, bilinear=self.bilinear)\n+        self.layer6 = Up(1024, 512, bilinear=bilinear)\n+        self.layer7 = Up(512, 256, bilinear=bilinear)\n+        self.layer8 = Up(256, 128, bilinear=bilinear)\n+        self.layer9 = Up(128, 64, bilinear=bilinear)\n \n-        self.layer10 = nn.Conv2d(64, self.num_classes, kernel_size=1)\n+        self.layer10 = nn.Conv2d(64, num_classes, kernel_size=1)\n \n     def forward(self, x):\n         x1 = self.layer1(x)\n", "issue": "Fix segmentation example\n# Before submitting\r\n\r\n- [x] Was this discussed/approved via a Github issue? (no need for typos, doc improvements)\r\n- [x] Did you read the [contributor guideline](https://github.com/PyTorchLightning/pytorch-lightning/blob/master/.github/CONTRIBUTING.md)?\r\n- [x] Did you make sure to update the docs?   \r\n- [ ] Did you write any new necessary tests?  \r\n\r\n## What does this PR do?\r\nFixes #874 (issue).\r\n\r\n## PR review    \r\nAnyone in the community is free to review the PR once the tests have passed. \r\n\r\n## Some comments\r\nI have added a custom model (UNet) instead of the previous torchvision segmentation model as it was causing tests to fail (mostly because those torchvision models were introduced in version 0.3 and it will fail for previous versions).\n", "before_files": [{"content": "import torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\nfrom parts import DoubleConv, Down, Up\n\n\nclass UNet(nn.Module):\n    '''\n    Architecture based on U-Net: Convolutional Networks for Biomedical Image Segmentation\n    Link - https://arxiv.org/abs/1505.04597\n    '''\n    def __init__(self, num_classes=19, bilinear=False):\n        super().__init__()\n        self.bilinear = bilinear\n        self.num_classes = num_classes\n        self.layer1 = DoubleConv(3, 64)\n        self.layer2 = Down(64, 128)\n        self.layer3 = Down(128, 256)\n        self.layer4 = Down(256, 512)\n        self.layer5 = Down(512, 1024)\n\n        self.layer6 = Up(1024, 512, bilinear=self.bilinear)\n        self.layer7 = Up(512, 256, bilinear=self.bilinear)\n        self.layer8 = Up(256, 128, bilinear=self.bilinear)\n        self.layer9 = Up(128, 64, bilinear=self.bilinear)\n\n        self.layer10 = nn.Conv2d(64, self.num_classes, kernel_size=1)\n\n    def forward(self, x):\n        x1 = self.layer1(x)\n        x2 = self.layer2(x1)\n        x3 = self.layer3(x2)\n        x4 = self.layer4(x3)\n        x5 = self.layer5(x4)\n\n        x6 = self.layer6(x5, x4)\n        x6 = self.layer7(x6, x3)\n        x6 = self.layer8(x6, x2)\n        x6 = self.layer9(x6, x1)\n\n        return self.layer10(x6)\n", "path": "pl_examples/full_examples/semantic_segmentation/models/unet/model.py"}, {"content": "# For relative imports to work in Python 3.6\nimport os\nimport sys\nsys.path.append(os.path.dirname(os.path.realpath(__file__)))\n", "path": "pl_examples/full_examples/semantic_segmentation/models/unet/__init__.py"}]}