prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  pretrain models for FCN and DeepLabV3
  Is it possible to provide the pretrain weight for deeplabv3 and FCN?
  right now when i do:
  `model = torchvision.models.segmentation.fcn_resnet50(pretrained=True)`
  I receive this:
  
  > NotImplementedError: pretrained fcn_resnet50_coco is not supported as of now
  
  </issue>
  <code>
  [start of torchvision/models/segmentation/segmentation.py]
  1 from .._utils import IntermediateLayerGetter
  2 from ..utils import load_state_dict_from_url
  3 from .. import resnet
  4 from .deeplabv3 import DeepLabHead, DeepLabV3
  5 from .fcn import FCN, FCNHead
  6 
  7 
  8 __all__ = ['fcn_resnet50', 'fcn_resnet101', 'deeplabv3_resnet50', 'deeplabv3_resnet101']
  9 
  10 
  11 model_urls = {
  12     'fcn_resnet50_coco': None,
  13     'fcn_resnet101_coco': 'https://download.pytorch.org/models/fcn_resnet101_coco-7ecb50ca.pth',
  14     'deeplabv3_resnet50_coco': None,
  15     'deeplabv3_resnet101_coco': 'https://download.pytorch.org/models/deeplabv3_resnet101_coco-586e9e4e.pth',
  16 }
  17 
  18 
  19 def _segm_resnet(name, backbone_name, num_classes, aux, pretrained_backbone=True):
  20     backbone = resnet.__dict__[backbone_name](
  21         pretrained=pretrained_backbone,
  22         replace_stride_with_dilation=[False, True, True])
  23 
  24     return_layers = {'layer4': 'out'}
  25     if aux:
  26         return_layers['layer3'] = 'aux'
  27     backbone = IntermediateLayerGetter(backbone, return_layers=return_layers)
  28 
  29     aux_classifier = None
  30     if aux:
  31         inplanes = 1024
  32         aux_classifier = FCNHead(inplanes, num_classes)
  33 
  34     model_map = {
  35         'deeplabv3': (DeepLabHead, DeepLabV3),
  36         'fcn': (FCNHead, FCN),
  37     }
  38     inplanes = 2048
  39     classifier = model_map[name][0](inplanes, num_classes)
  40     base_model = model_map[name][1]
  41 
  42     model = base_model(backbone, classifier, aux_classifier)
  43     return model
  44 
  45 
  46 def _load_model(arch_type, backbone, pretrained, progress, num_classes, aux_loss, **kwargs):
  47     if pretrained:
  48         aux_loss = True
  49     model = _segm_resnet(arch_type, backbone, num_classes, aux_loss, **kwargs)
  50     if pretrained:
  51         arch = arch_type + '_' + backbone + '_coco'
  52         model_url = model_urls[arch]
  53         if model_url is None:
  54             raise NotImplementedError('pretrained {} is not supported as of now'.format(arch))
  55         else:
  56             state_dict = load_state_dict_from_url(model_url, progress=progress)
  57             model.load_state_dict(state_dict)
  58     return model
  59 
  60 
  61 def fcn_resnet50(pretrained=False, progress=True,
  62                  num_classes=21, aux_loss=None, **kwargs):
  63     """Constructs a Fully-Convolutional Network model with a ResNet-50 backbone.
  64 
  65     Args:
  66         pretrained (bool): If True, returns a model pre-trained on COCO train2017 which
  67             contains the same classes as Pascal VOC
  68         progress (bool): If True, displays a progress bar of the download to stderr
  69     """
  70     return _load_model('fcn', 'resnet50', pretrained, progress, num_classes, aux_loss, **kwargs)
  71 
  72 
  73 def fcn_resnet101(pretrained=False, progress=True,
  74                   num_classes=21, aux_loss=None, **kwargs):
  75     """Constructs a Fully-Convolutional Network model with a ResNet-101 backbone.
  76 
  77     Args:
  78         pretrained (bool): If True, returns a model pre-trained on COCO train2017 which
  79             contains the same classes as Pascal VOC
  80         progress (bool): If True, displays a progress bar of the download to stderr
  81     """
  82     return _load_model('fcn', 'resnet101', pretrained, progress, num_classes, aux_loss, **kwargs)
  83 
  84 
  85 def deeplabv3_resnet50(pretrained=False, progress=True,
  86                        num_classes=21, aux_loss=None, **kwargs):
  87     """Constructs a DeepLabV3 model with a ResNet-50 backbone.
  88 
  89     Args:
  90         pretrained (bool): If True, returns a model pre-trained on COCO train2017 which
  91             contains the same classes as Pascal VOC
  92         progress (bool): If True, displays a progress bar of the download to stderr
  93     """
  94     return _load_model('deeplabv3', 'resnet50', pretrained, progress, num_classes, aux_loss, **kwargs)
  95 
  96 
  97 def deeplabv3_resnet101(pretrained=False, progress=True,
  98                         num_classes=21, aux_loss=None, **kwargs):
  99     """Constructs a DeepLabV3 model with a ResNet-101 backbone.
  100 
  101     Args:
  102         pretrained (bool): If True, returns a model pre-trained on COCO train2017 which
  103             contains the same classes as Pascal VOC
  104         progress (bool): If True, displays a progress bar of the download to stderr
  105     """
  106     return _load_model('deeplabv3', 'resnet101', pretrained, progress, num_classes, aux_loss, **kwargs)
  107
  [end of torchvision/models/segmentation/segmentation.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/torchvision/models/segmentation/segmentation.py b/torchvision/models/segmentation/segmentation.py
  --- a/torchvision/models/segmentation/segmentation.py
  +++ b/torchvision/models/segmentation/segmentation.py
  @@ -9,9 +9,9 @@
   
   
   model_urls = {
  -    'fcn_resnet50_coco': None,
  +    'fcn_resnet50_coco': 'https://download.pytorch.org/models/fcn_resnet50_coco-1167a1af.pth',
       'fcn_resnet101_coco': 'https://download.pytorch.org/models/fcn_resnet101_coco-7ecb50ca.pth',
  -    'deeplabv3_resnet50_coco': None,
  +    'deeplabv3_resnet50_coco': 'https://download.pytorch.org/models/deeplabv3_resnet50_coco-cd0a2569.pth',
       'deeplabv3_resnet101_coco': 'https://download.pytorch.org/models/deeplabv3_resnet101_coco-586e9e4e.pth',
   }
  
verification_info: {"golden_diff": "diff --git a/torchvision/models/segmentation/segmentation.py b/torchvision/models/segmentation/segmentation.py\n--- a/torchvision/models/segmentation/segmentation.py\n+++ b/torchvision/models/segmentation/segmentation.py\n@@ -9,9 +9,9 @@\n \n \n model_urls = {\n-    'fcn_resnet50_coco': None,\n+    'fcn_resnet50_coco': 'https://download.pytorch.org/models/fcn_resnet50_coco-1167a1af.pth',\n     'fcn_resnet101_coco': 'https://download.pytorch.org/models/fcn_resnet101_coco-7ecb50ca.pth',\n-    'deeplabv3_resnet50_coco': None,\n+    'deeplabv3_resnet50_coco': 'https://download.pytorch.org/models/deeplabv3_resnet50_coco-cd0a2569.pth',\n     'deeplabv3_resnet101_coco': 'https://download.pytorch.org/models/deeplabv3_resnet101_coco-586e9e4e.pth',\n }\n", "issue": "pretrain models for FCN and DeepLabV3\nIs it possible to provide the pretrain weight for deeplabv3 and FCN?\r\nright now when i do:\r\n`model = torchvision.models.segmentation.fcn_resnet50(pretrained=True)`\r\nI receive this:\r\n\r\n> NotImplementedError: pretrained fcn_resnet50_coco is not supported as of now\n", "before_files": [{"content": "from .._utils import IntermediateLayerGetter\nfrom ..utils import load_state_dict_from_url\nfrom .. import resnet\nfrom .deeplabv3 import DeepLabHead, DeepLabV3\nfrom .fcn import FCN, FCNHead\n\n\n__all__ = ['fcn_resnet50', 'fcn_resnet101', 'deeplabv3_resnet50', 'deeplabv3_resnet101']\n\n\nmodel_urls = {\n    'fcn_resnet50_coco': None,\n    'fcn_resnet101_coco': 'https://download.pytorch.org/models/fcn_resnet101_coco-7ecb50ca.pth',\n    'deeplabv3_resnet50_coco': None,\n    'deeplabv3_resnet101_coco': 'https://download.pytorch.org/models/deeplabv3_resnet101_coco-586e9e4e.pth',\n}\n\n\ndef _segm_resnet(name, backbone_name, num_classes, aux, pretrained_backbone=True):\n    backbone = resnet.__dict__[backbone_name](\n        pretrained=pretrained_backbone,\n        replace_stride_with_dilation=[False, True, True])\n\n    return_layers = {'layer4': 'out'}\n    if aux:\n        return_layers['layer3'] = 'aux'\n    backbone = IntermediateLayerGetter(backbone, return_layers=return_layers)\n\n    aux_classifier = None\n    if aux:\n        inplanes = 1024\n        aux_classifier = FCNHead(inplanes, num_classes)\n\n    model_map = {\n        'deeplabv3': (DeepLabHead, DeepLabV3),\n        'fcn': (FCNHead, FCN),\n    }\n    inplanes = 2048\n    classifier = model_map[name][0](inplanes, num_classes)\n    base_model = model_map[name][1]\n\n    model = base_model(backbone, classifier, aux_classifier)\n    return model\n\n\ndef _load_model(arch_type, backbone, pretrained, progress, num_classes, aux_loss, **kwargs):\n    if pretrained:\n        aux_loss = True\n    model = _segm_resnet(arch_type, backbone, num_classes, aux_loss, **kwargs)\n    if pretrained:\n        arch = arch_type + '_' + backbone + '_coco'\n        model_url = model_urls[arch]\n        if model_url is None:\n            raise NotImplementedError('pretrained {} is not supported as of now'.format(arch))\n        else:\n            state_dict = load_state_dict_from_url(model_url, progress=progress)\n            model.load_state_dict(state_dict)\n    return model\n\n\ndef fcn_resnet50(pretrained=False, progress=True,\n                 num_classes=21, aux_loss=None, **kwargs):\n    \"\"\"Constructs a Fully-Convolutional Network model with a ResNet-50 backbone.\n\n    Args:\n        pretrained (bool): If True, returns a model pre-trained on COCO train2017 which\n            contains the same classes as Pascal VOC\n        progress (bool): If True, displays a progress bar of the download to stderr\n    \"\"\"\n    return _load_model('fcn', 'resnet50', pretrained, progress, num_classes, aux_loss, **kwargs)\n\n\ndef fcn_resnet101(pretrained=False, progress=True,\n                  num_classes=21, aux_loss=None, **kwargs):\n    \"\"\"Constructs a Fully-Convolutional Network model with a ResNet-101 backbone.\n\n    Args:\n        pretrained (bool): If True, returns a model pre-trained on COCO train2017 which\n            contains the same classes as Pascal VOC\n        progress (bool): If True, displays a progress bar of the download to stderr\n    \"\"\"\n    return _load_model('fcn', 'resnet101', pretrained, progress, num_classes, aux_loss, **kwargs)\n\n\ndef deeplabv3_resnet50(pretrained=False, progress=True,\n                       num_classes=21, aux_loss=None, **kwargs):\n    \"\"\"Constructs a DeepLabV3 model with a ResNet-50 backbone.\n\n    Args:\n        pretrained (bool): If True, returns a model pre-trained on COCO train2017 which\n            contains the same classes as Pascal VOC\n        progress (bool): If True, displays a progress bar of the download to stderr\n    \"\"\"\n    return _load_model('deeplabv3', 'resnet50', pretrained, progress, num_classes, aux_loss, **kwargs)\n\n\ndef deeplabv3_resnet101(pretrained=False, progress=True,\n                        num_classes=21, aux_loss=None, **kwargs):\n    \"\"\"Constructs a DeepLabV3 model with a ResNet-101 backbone.\n\n    Args:\n        pretrained (bool): If True, returns a model pre-trained on COCO train2017 which\n            contains the same classes as Pascal VOC\n        progress (bool): If True, displays a progress bar of the download to stderr\n    \"\"\"\n    return _load_model('deeplabv3', 'resnet101', pretrained, progress, num_classes, aux_loss, **kwargs)\n", "path": "torchvision/models/segmentation/segmentation.py"}]}