prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Tracking: mxnet 1.6
  ### To update
  
  - [x] documentation
  - [x] README.md
  - [x] test-dependencies
  
  ### Fix
  
  - [x] https://github.com/awslabs/gluon-ts/issues/583
  
  ### Other
  
  - [x] Update `numpy~1.18`
  
  </issue>
  <code>
  [start of src/gluonts/model/seq2seq/_forking_network.py]
  1 # Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  2 #
  3 # Licensed under the Apache License, Version 2.0 (the "License").
  4 # You may not use this file except in compliance with the License.
  5 # A copy of the License is located at
  6 #
  7 #     http://www.apache.org/licenses/LICENSE-2.0
  8 #
  9 # or in the "license" file accompanying this file. This file is distributed
  10 # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  11 # express or implied. See the License for the specific language governing
  12 # permissions and limitations under the License.
  13 
  14 # Third-party imports
  15 from mxnet import gluon, nd
  16 
  17 # First-party imports
  18 from gluonts.block.decoder import Seq2SeqDecoder
  19 from gluonts.block.enc2dec import Seq2SeqEnc2Dec
  20 from gluonts.block.encoder import Seq2SeqEncoder
  21 from gluonts.block.quantile_output import QuantileOutput
  22 from gluonts.core.component import validated
  23 from gluonts.model.common import Tensor
  24 
  25 nd_None = nd.array([])
  26 
  27 
  28 class ForkingSeq2SeqNetworkBase(gluon.HybridBlock):
  29     """
  30     Base network for the :class:`ForkingSeq2SeqEstimator`.
  31 
  32     Parameters
  33     ----------
  34     encoder: Seq2SeqEncoder
  35         encoder block
  36     enc2dec: Seq2SeqEnc2Dec
  37         encoder to decoder mapping block
  38     decoder: Seq2SeqDecoder
  39         decoder block
  40     quantile_output: QuantileOutput
  41         quantile output block
  42     kwargs: dict
  43         dictionary of Gluon HybridBlock parameters
  44     """
  45 
  46     @validated()
  47     def __init__(
  48         self,
  49         encoder: Seq2SeqEncoder,
  50         enc2dec: Seq2SeqEnc2Dec,
  51         decoder: Seq2SeqDecoder,
  52         quantile_output: QuantileOutput,
  53         **kwargs,
  54     ) -> None:
  55         super().__init__(**kwargs)
  56 
  57         self.encoder = encoder
  58         self.enc2dec = enc2dec
  59         self.decoder = decoder
  60         self.quantile_output = quantile_output
  61 
  62         with self.name_scope():
  63             self.quantile_proj = quantile_output.get_quantile_proj()
  64             self.loss = quantile_output.get_loss()
  65 
  66 
  67 class ForkingSeq2SeqTrainingNetwork(ForkingSeq2SeqNetworkBase):
  68     # noinspection PyMethodOverriding
  69     def hybrid_forward(
  70         self, F, past_target: Tensor, future_target: Tensor
  71     ) -> Tensor:
  72         """
  73         Parameters
  74         ----------
  75         F: mx.symbol or mx.ndarray
  76             Gluon function space
  77         past_target: Tensor
  78             FIXME
  79         future_target: Tensor
  80             shape (num_ts, encoder_length, 1) FIXME
  81 
  82         Returns
  83         -------
  84         loss with shape (FIXME, FIXME)
  85         """
  86 
  87         # FIXME: can we factor out a common prefix in the base network?
  88         feat_static_real = nd_None
  89         past_feat_dynamic_real = nd_None
  90         future_feat_dynamic_real = nd_None
  91 
  92         enc_output_static, enc_output_dynamic = self.encoder(
  93             past_target, feat_static_real, past_feat_dynamic_real
  94         )
  95 
  96         dec_input_static, dec_input_dynamic, _ = self.enc2dec(
  97             enc_output_static, enc_output_dynamic, future_feat_dynamic_real
  98         )
  99 
  100         dec_output = self.decoder(dec_input_dynamic, dec_input_static)
  101         dec_dist_output = self.quantile_proj(dec_output)
  102 
  103         loss = self.loss(future_target, dec_dist_output)
  104         return loss.mean(axis=1)
  105 
  106 
  107 class ForkingSeq2SeqPredictionNetwork(ForkingSeq2SeqNetworkBase):
  108     # noinspection PyMethodOverriding
  109     def hybrid_forward(self, F, past_target: Tensor) -> Tensor:
  110         """
  111         Parameters
  112         ----------
  113         F: mx.symbol or mx.ndarray
  114             Gluon function space
  115         past_target: Tensor
  116             FIXME
  117 
  118         Returns
  119         -------
  120         prediction tensor with shape (FIXME, FIXME)
  121         """
  122 
  123         # FIXME: can we factor out a common prefix in the base network?
  124         feat_static_real = nd_None
  125         past_feat_dynamic_real = nd_None
  126         future_feat_dynamic_real = nd_None
  127 
  128         enc_output_static, enc_output_dynamic = self.encoder(
  129             past_target, feat_static_real, past_feat_dynamic_real
  130         )
  131 
  132         enc_output_static = (
  133             nd_None if enc_output_static is None else enc_output_static
  134         )
  135 
  136         dec_inp_static, dec_inp_dynamic, _ = self.enc2dec(
  137             enc_output_static, enc_output_dynamic, future_feat_dynamic_real
  138         )
  139 
  140         dec_output = self.decoder(dec_inp_dynamic, dec_inp_static)
  141         fcst_output = F.slice_axis(dec_output, axis=1, begin=-1, end=None)
  142         fcst_output = F.squeeze(fcst_output, axis=1)
  143 
  144         predictions = self.quantile_proj(fcst_output).swapaxes(2, 1)
  145         return predictions
  146
  [end of src/gluonts/model/seq2seq/_forking_network.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/src/gluonts/model/seq2seq/_forking_network.py b/src/gluonts/model/seq2seq/_forking_network.py
  --- a/src/gluonts/model/seq2seq/_forking_network.py
  +++ b/src/gluonts/model/seq2seq/_forking_network.py
  @@ -12,7 +12,8 @@
   # permissions and limitations under the License.
   
   # Third-party imports
  -from mxnet import gluon, nd
  +import mxnet as mx
  +from mxnet import gluon
   
   # First-party imports
   from gluonts.block.decoder import Seq2SeqDecoder
  @@ -22,8 +23,6 @@
   from gluonts.core.component import validated
   from gluonts.model.common import Tensor
   
  -nd_None = nd.array([])
  -
   
   class ForkingSeq2SeqNetworkBase(gluon.HybridBlock):
       """
  @@ -85,9 +84,9 @@
           """
   
           # FIXME: can we factor out a common prefix in the base network?
  -        feat_static_real = nd_None
  -        past_feat_dynamic_real = nd_None
  -        future_feat_dynamic_real = nd_None
  +        feat_static_real = F.zeros(shape=(1,))
  +        past_feat_dynamic_real = F.zeros(shape=(1,))
  +        future_feat_dynamic_real = F.zeros(shape=(1,))
   
           enc_output_static, enc_output_dynamic = self.encoder(
               past_target, feat_static_real, past_feat_dynamic_real
  @@ -121,16 +120,18 @@
           """
   
           # FIXME: can we factor out a common prefix in the base network?
  -        feat_static_real = nd_None
  -        past_feat_dynamic_real = nd_None
  -        future_feat_dynamic_real = nd_None
  +        feat_static_real = F.zeros(shape=(1,))
  +        past_feat_dynamic_real = F.zeros(shape=(1,))
  +        future_feat_dynamic_real = F.zeros(shape=(1,))
   
           enc_output_static, enc_output_dynamic = self.encoder(
               past_target, feat_static_real, past_feat_dynamic_real
           )
   
           enc_output_static = (
  -            nd_None if enc_output_static is None else enc_output_static
  +            F.zeros(shape=(1,))
  +            if enc_output_static is None
  +            else enc_output_static
           )
   
           dec_inp_static, dec_inp_dynamic, _ = self.enc2dec(
  
verification_info: {"golden_diff": "diff --git a/src/gluonts/model/seq2seq/_forking_network.py b/src/gluonts/model/seq2seq/_forking_network.py\n--- a/src/gluonts/model/seq2seq/_forking_network.py\n+++ b/src/gluonts/model/seq2seq/_forking_network.py\n@@ -12,7 +12,8 @@\n # permissions and limitations under the License.\n \n # Third-party imports\n-from mxnet import gluon, nd\n+import mxnet as mx\n+from mxnet import gluon\n \n # First-party imports\n from gluonts.block.decoder import Seq2SeqDecoder\n@@ -22,8 +23,6 @@\n from gluonts.core.component import validated\n from gluonts.model.common import Tensor\n \n-nd_None = nd.array([])\n-\n \n class ForkingSeq2SeqNetworkBase(gluon.HybridBlock):\n     \"\"\"\n@@ -85,9 +84,9 @@\n         \"\"\"\n \n         # FIXME: can we factor out a common prefix in the base network?\n-        feat_static_real = nd_None\n-        past_feat_dynamic_real = nd_None\n-        future_feat_dynamic_real = nd_None\n+        feat_static_real = F.zeros(shape=(1,))\n+        past_feat_dynamic_real = F.zeros(shape=(1,))\n+        future_feat_dynamic_real = F.zeros(shape=(1,))\n \n         enc_output_static, enc_output_dynamic = self.encoder(\n             past_target, feat_static_real, past_feat_dynamic_real\n@@ -121,16 +120,18 @@\n         \"\"\"\n \n         # FIXME: can we factor out a common prefix in the base network?\n-        feat_static_real = nd_None\n-        past_feat_dynamic_real = nd_None\n-        future_feat_dynamic_real = nd_None\n+        feat_static_real = F.zeros(shape=(1,))\n+        past_feat_dynamic_real = F.zeros(shape=(1,))\n+        future_feat_dynamic_real = F.zeros(shape=(1,))\n \n         enc_output_static, enc_output_dynamic = self.encoder(\n             past_target, feat_static_real, past_feat_dynamic_real\n         )\n \n         enc_output_static = (\n-            nd_None if enc_output_static is None else enc_output_static\n+            F.zeros(shape=(1,))\n+            if enc_output_static is None\n+            else enc_output_static\n         )\n \n         dec_inp_static, dec_inp_dynamic, _ = self.enc2dec(\n", "issue": "Tracking: mxnet 1.6\n### To update\r\n\r\n- [x] documentation\r\n- [x] README.md\r\n- [x] test-dependencies\r\n\r\n### Fix\r\n\r\n- [x] https://github.com/awslabs/gluon-ts/issues/583\r\n\r\n### Other\r\n\r\n- [x] Update `numpy~1.18`\n", "before_files": [{"content": "# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\").\n# You may not use this file except in compliance with the License.\n# A copy of the License is located at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# or in the \"license\" file accompanying this file. This file is distributed\n# on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\n# express or implied. See the License for the specific language governing\n# permissions and limitations under the License.\n\n# Third-party imports\nfrom mxnet import gluon, nd\n\n# First-party imports\nfrom gluonts.block.decoder import Seq2SeqDecoder\nfrom gluonts.block.enc2dec import Seq2SeqEnc2Dec\nfrom gluonts.block.encoder import Seq2SeqEncoder\nfrom gluonts.block.quantile_output import QuantileOutput\nfrom gluonts.core.component import validated\nfrom gluonts.model.common import Tensor\n\nnd_None = nd.array([])\n\n\nclass ForkingSeq2SeqNetworkBase(gluon.HybridBlock):\n    \"\"\"\n    Base network for the :class:`ForkingSeq2SeqEstimator`.\n\n    Parameters\n    ----------\n    encoder: Seq2SeqEncoder\n        encoder block\n    enc2dec: Seq2SeqEnc2Dec\n        encoder to decoder mapping block\n    decoder: Seq2SeqDecoder\n        decoder block\n    quantile_output: QuantileOutput\n        quantile output block\n    kwargs: dict\n        dictionary of Gluon HybridBlock parameters\n    \"\"\"\n\n    @validated()\n    def __init__(\n        self,\n        encoder: Seq2SeqEncoder,\n        enc2dec: Seq2SeqEnc2Dec,\n        decoder: Seq2SeqDecoder,\n        quantile_output: QuantileOutput,\n        **kwargs,\n    ) -> None:\n        super().__init__(**kwargs)\n\n        self.encoder = encoder\n        self.enc2dec = enc2dec\n        self.decoder = decoder\n        self.quantile_output = quantile_output\n\n        with self.name_scope():\n            self.quantile_proj = quantile_output.get_quantile_proj()\n            self.loss = quantile_output.get_loss()\n\n\nclass ForkingSeq2SeqTrainingNetwork(ForkingSeq2SeqNetworkBase):\n    # noinspection PyMethodOverriding\n    def hybrid_forward(\n        self, F, past_target: Tensor, future_target: Tensor\n    ) -> Tensor:\n        \"\"\"\n        Parameters\n        ----------\n        F: mx.symbol or mx.ndarray\n            Gluon function space\n        past_target: Tensor\n            FIXME\n        future_target: Tensor\n            shape (num_ts, encoder_length, 1) FIXME\n\n        Returns\n        -------\n        loss with shape (FIXME, FIXME)\n        \"\"\"\n\n        # FIXME: can we factor out a common prefix in the base network?\n        feat_static_real = nd_None\n        past_feat_dynamic_real = nd_None\n        future_feat_dynamic_real = nd_None\n\n        enc_output_static, enc_output_dynamic = self.encoder(\n            past_target, feat_static_real, past_feat_dynamic_real\n        )\n\n        dec_input_static, dec_input_dynamic, _ = self.enc2dec(\n            enc_output_static, enc_output_dynamic, future_feat_dynamic_real\n        )\n\n        dec_output = self.decoder(dec_input_dynamic, dec_input_static)\n        dec_dist_output = self.quantile_proj(dec_output)\n\n        loss = self.loss(future_target, dec_dist_output)\n        return loss.mean(axis=1)\n\n\nclass ForkingSeq2SeqPredictionNetwork(ForkingSeq2SeqNetworkBase):\n    # noinspection PyMethodOverriding\n    def hybrid_forward(self, F, past_target: Tensor) -> Tensor:\n        \"\"\"\n        Parameters\n        ----------\n        F: mx.symbol or mx.ndarray\n            Gluon function space\n        past_target: Tensor\n            FIXME\n\n        Returns\n        -------\n        prediction tensor with shape (FIXME, FIXME)\n        \"\"\"\n\n        # FIXME: can we factor out a common prefix in the base network?\n        feat_static_real = nd_None\n        past_feat_dynamic_real = nd_None\n        future_feat_dynamic_real = nd_None\n\n        enc_output_static, enc_output_dynamic = self.encoder(\n            past_target, feat_static_real, past_feat_dynamic_real\n        )\n\n        enc_output_static = (\n            nd_None if enc_output_static is None else enc_output_static\n        )\n\n        dec_inp_static, dec_inp_dynamic, _ = self.enc2dec(\n            enc_output_static, enc_output_dynamic, future_feat_dynamic_real\n        )\n\n        dec_output = self.decoder(dec_inp_dynamic, dec_inp_static)\n        fcst_output = F.slice_axis(dec_output, axis=1, begin=-1, end=None)\n        fcst_output = F.squeeze(fcst_output, axis=1)\n\n        predictions = self.quantile_proj(fcst_output).swapaxes(2, 1)\n        return predictions\n", "path": "src/gluonts/model/seq2seq/_forking_network.py"}]}