We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
PyTorch 0.4 test errors
Need to fix these:

```
..........
----------------------------------------------------------------------
Ran 10 tests in 0.015s

OK
E.../Users/szagoruyko/anaconda3/lib/python3.6/site-packages/numpy/core/_methods.py:135: RuntimeWarning: Degrees of freedom <= 0 for slice
  keepdims=keepdims)
/Users/szagoruyko/anaconda3/lib/python3.6/site-packages/numpy/core/_methods.py:127: RuntimeWarning: invalid value encountered in double_scalars
  ret = ret.dtype.type(ret / rcount)
.....E
======================================================================
ERROR: testAPMeter (__main__.TestMeters)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_meters.py", line 208, in testAPMeter
    ap = mtr.value()
  File "/Users/szagoruyko/anaconda3/lib/python3.6/site-packages/torchnet/meter/apmeter.py", line 137, in value
    ap[k] = precision[truth.byte()].sum() / max(truth.sum(), 1)
RuntimeError: Expected object of type torch.FloatTensor but found type torch.LongTensor for argument #2 'other'

======================================================================
ERROR: testmAPMeter (__main__.TestMeters)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_meters.py", line 329, in testmAPMeter
    ap = mtr.value()
  File "/Users/szagoruyko/anaconda3/lib/python3.6/site-packages/torchnet/meter/mapmeter.py", line 30, in value
    return self.apmeter.value().mean()
  File "/Users/szagoruyko/anaconda3/lib/python3.6/site-packages/torchnet/meter/apmeter.py", line 137, in value
    ap[k] = precision[truth.byte()].sum() / max(truth.sum(), 1)
RuntimeError: Expected object of type torch.FloatTensor but found type torch.LongTensor for argument #2 'other'

----------------------------------------------------------------------
Ran 10 tests in 0.118s

FAILED (errors=2)
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `torchnet/meter/apmeter.py`
Content:
```
1 import math
2 from . import meter
3 import torch
4 
5 
6 class APMeter(meter.Meter):
7     """
8     The APMeter measures the average precision per class.
9 
10     The APMeter is designed to operate on `NxK` Tensors `output` and
11     `target`, and optionally a `Nx1` Tensor weight where (1) the `output`
12     contains model output scores for `N` examples and `K` classes that ought to
13     be higher when the model is more convinced that the example should be
14     positively labeled, and smaller when the model believes the example should
15     be negatively labeled (for instance, the output of a sigmoid function); (2)
16     the `target` contains only values 0 (for negative examples) and 1
17     (for positive examples); and (3) the `weight` ( > 0) represents weight for
18     each sample.
19     """
20 
21     def __init__(self):
22         super(APMeter, self).__init__()
23         self.reset()
24 
25     def reset(self):
26         """Resets the meter with empty member variables"""
27         self.scores = torch.FloatTensor(torch.FloatStorage())
28         self.targets = torch.LongTensor(torch.LongStorage())
29         self.weights = torch.FloatTensor(torch.FloatStorage())
30 
31     def add(self, output, target, weight=None):
32         """
33         Args:
34             output (Tensor): NxK tensor that for each of the N examples
35                 indicates the probability of the example belonging to each of
36                 the K classes, according to the model. The probabilities should
37                 sum to one over all classes
38             target (Tensor): binary NxK tensort that encodes which of the K
39                 classes are associated with the N-th input
40                     (eg: a row [0, 1, 0, 1] indicates that the example is
41                          associated with classes 2 and 4)
42             weight (optional, Tensor): Nx1 tensor representing the weight for
43                 each example (each weight > 0)
44         """
45         if not torch.is_tensor(output):
46             output = torch.from_numpy(output)
47         if not torch.is_tensor(target):
48             target = torch.from_numpy(target)
49 
50         if weight is not None:
51             if not torch.is_tensor(weight):
52                 weight = torch.from_numpy(weight)
53             weight = weight.squeeze()
54         if output.dim() == 1:
55             output = output.view(-1, 1)
56         else:
57             assert output.dim() == 2, \
58                 'wrong output size (should be 1D or 2D with one column \
59                 per class)'
60         if target.dim() == 1:
61             target = target.view(-1, 1)
62         else:
63             assert target.dim() == 2, \
64                 'wrong target size (should be 1D or 2D with one column \
65                 per class)'
66         if weight is not None:
67             assert weight.dim() == 1, 'Weight dimension should be 1'
68             assert weight.numel() == target.size(0), \
69                 'Weight dimension 1 should be the same as that of target'
70             assert torch.min(weight) >= 0, 'Weight should be non-negative only'
71         assert torch.equal(target**2, target), \
72             'targets should be binary (0 or 1)'
73         if self.scores.numel() > 0:
74             assert target.size(1) == self.targets.size(1), \
75                 'dimensions for output should match previously added examples.'
76 
77         # make sure storage is of sufficient size
78         if self.scores.storage().size() < self.scores.numel() + output.numel():
79             new_size = math.ceil(self.scores.storage().size() * 1.5)
80             new_weight_size = math.ceil(self.weights.storage().size() * 1.5)
81             self.scores.storage().resize_(int(new_size + output.numel()))
82             self.targets.storage().resize_(int(new_size + output.numel()))
83             if weight is not None:
84                 self.weights.storage().resize_(int(new_weight_size + output.size(0)))
85 
86         # store scores and targets
87         offset = self.scores.size(0) if self.scores.dim() > 0 else 0
88         self.scores.resize_(offset + output.size(0), output.size(1))
89         self.targets.resize_(offset + target.size(0), target.size(1))
90         self.scores.narrow(0, offset, output.size(0)).copy_(output)
91         self.targets.narrow(0, offset, target.size(0)).copy_(target)
92 
93         if weight is not None:
94             self.weights.resize_(offset + weight.size(0))
95             self.weights.narrow(0, offset, weight.size(0)).copy_(weight)
96 
97     def value(self):
98         """Returns the model's average precision for each class
99 
100         Return:
101             ap (FloatTensor): 1xK tensor, with avg precision for each class k
102         """
103 
104         if self.scores.numel() == 0:
105             return 0
106         ap = torch.zeros(self.scores.size(1))
107         if hasattr(torch, "arange"):
108             rg = torch.arange(1, self.scores.size(0) + 1).float()
109         else:
110             rg = torch.range(1, self.scores.size(0)).float()
111         if self.weights.numel() > 0:
112             weight = self.weights.new(self.weights.size())
113             weighted_truth = self.weights.new(self.weights.size())
114 
115         # compute average precision for each class
116         for k in range(self.scores.size(1)):
117             # sort scores
118             scores = self.scores[:, k]
119             targets = self.targets[:, k]
120             _, sortind = torch.sort(scores, 0, True)
121             truth = targets[sortind]
122             if self.weights.numel() > 0:
123                 weight = self.weights[sortind]
124                 weighted_truth = truth.float() * weight
125                 rg = weight.cumsum(0)
126 
127             # compute true positive sums
128             if self.weights.numel() > 0:
129                 tp = weighted_truth.cumsum(0)
130             else:
131                 tp = truth.float().cumsum(0)
132 
133             # compute precision curve
134             precision = tp.div(rg)
135 
136             # compute average precision
137             ap[k] = precision[truth.byte()].sum() / max(truth.sum(), 1)
138         return ap
139
```
--- 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/torchnet/meter/apmeter.py b/torchnet/meter/apmeter.py
--- a/torchnet/meter/apmeter.py
+++ b/torchnet/meter/apmeter.py
@@ -134,5 +134,5 @@
             precision = tp.div(rg)
 
             # compute average precision
-            ap[k] = precision[truth.byte()].sum() / max(truth.sum(), 1)
+            ap[k] = precision[truth.byte()].sum() / max(float(truth.sum()), 1)
         return ap

{"golden_diff": "diff --git a/torchnet/meter/apmeter.py b/torchnet/meter/apmeter.py\n--- a/torchnet/meter/apmeter.py\n+++ b/torchnet/meter/apmeter.py\n@@ -134,5 +134,5 @@\n             precision = tp.div(rg)\n \n             # compute average precision\n-            ap[k] = precision[truth.byte()].sum() / max(truth.sum(), 1)\n+            ap[k] = precision[truth.byte()].sum() / max(float(truth.sum()), 1)\n         return ap\n", "issue": "PyTorch 0.4 test errors\nNeed to fix these:\r\n\r\n```\r\n..........\r\n----------------------------------------------------------------------\r\nRan 10 tests in 0.015s\r\n\r\nOK\r\nE.../Users/szagoruyko/anaconda3/lib/python3.6/site-packages/numpy/core/_methods.py:135: RuntimeWarning: Degrees of freedom <= 0 for slice\r\n  keepdims=keepdims)\r\n/Users/szagoruyko/anaconda3/lib/python3.6/site-packages/numpy/core/_methods.py:127: RuntimeWarning: invalid value encountered in double_scalars\r\n  ret = ret.dtype.type(ret / rcount)\r\n.....E\r\n======================================================================\r\nERROR: testAPMeter (__main__.TestMeters)\r\n----------------------------------------------------------------------\r\nTraceback (most recent call last):\r\n  File \"test_meters.py\", line 208, in testAPMeter\r\n    ap = mtr.value()\r\n  File \"/Users/szagoruyko/anaconda3/lib/python3.6/site-packages/torchnet/meter/apmeter.py\", line 137, in value\r\n    ap[k] = precision[truth.byte()].sum() / max(truth.sum(), 1)\r\nRuntimeError: Expected object of type torch.FloatTensor but found type torch.LongTensor for argument #2 'other'\r\n\r\n======================================================================\r\nERROR: testmAPMeter (__main__.TestMeters)\r\n----------------------------------------------------------------------\r\nTraceback (most recent call last):\r\n  File \"test_meters.py\", line 329, in testmAPMeter\r\n    ap = mtr.value()\r\n  File \"/Users/szagoruyko/anaconda3/lib/python3.6/site-packages/torchnet/meter/mapmeter.py\", line 30, in value\r\n    return self.apmeter.value().mean()\r\n  File \"/Users/szagoruyko/anaconda3/lib/python3.6/site-packages/torchnet/meter/apmeter.py\", line 137, in value\r\n    ap[k] = precision[truth.byte()].sum() / max(truth.sum(), 1)\r\nRuntimeError: Expected object of type torch.FloatTensor but found type torch.LongTensor for argument #2 'other'\r\n\r\n----------------------------------------------------------------------\r\nRan 10 tests in 0.118s\r\n\r\nFAILED (errors=2)\r\n```\n", "before_files": [{"content": "import math\nfrom . import meter\nimport torch\n\n\nclass APMeter(meter.Meter):\n    \"\"\"\n    The APMeter measures the average precision per class.\n\n    The APMeter is designed to operate on `NxK` Tensors `output` and\n    `target`, and optionally a `Nx1` Tensor weight where (1) the `output`\n    contains model output scores for `N` examples and `K` classes that ought to\n    be higher when the model is more convinced that the example should be\n    positively labeled, and smaller when the model believes the example should\n    be negatively labeled (for instance, the output of a sigmoid function); (2)\n    the `target` contains only values 0 (for negative examples) and 1\n    (for positive examples); and (3) the `weight` ( > 0) represents weight for\n    each sample.\n    \"\"\"\n\n    def __init__(self):\n        super(APMeter, self).__init__()\n        self.reset()\n\n    def reset(self):\n        \"\"\"Resets the meter with empty member variables\"\"\"\n        self.scores = torch.FloatTensor(torch.FloatStorage())\n        self.targets = torch.LongTensor(torch.LongStorage())\n        self.weights = torch.FloatTensor(torch.FloatStorage())\n\n    def add(self, output, target, weight=None):\n        \"\"\"\n        Args:\n            output (Tensor): NxK tensor that for each of the N examples\n                indicates the probability of the example belonging to each of\n                the K classes, according to the model. The probabilities should\n                sum to one over all classes\n            target (Tensor): binary NxK tensort that encodes which of the K\n                classes are associated with the N-th input\n                    (eg: a row [0, 1, 0, 1] indicates that the example is\n                         associated with classes 2 and 4)\n            weight (optional, Tensor): Nx1 tensor representing the weight for\n                each example (each weight > 0)\n        \"\"\"\n        if not torch.is_tensor(output):\n            output = torch.from_numpy(output)\n        if not torch.is_tensor(target):\n            target = torch.from_numpy(target)\n\n        if weight is not None:\n            if not torch.is_tensor(weight):\n                weight = torch.from_numpy(weight)\n            weight = weight.squeeze()\n        if output.dim() == 1:\n            output = output.view(-1, 1)\n        else:\n            assert output.dim() == 2, \\\n                'wrong output size (should be 1D or 2D with one column \\\n                per class)'\n        if target.dim() == 1:\n            target = target.view(-1, 1)\n        else:\n            assert target.dim() == 2, \\\n                'wrong target size (should be 1D or 2D with one column \\\n                per class)'\n        if weight is not None:\n            assert weight.dim() == 1, 'Weight dimension should be 1'\n            assert weight.numel() == target.size(0), \\\n                'Weight dimension 1 should be the same as that of target'\n            assert torch.min(weight) >= 0, 'Weight should be non-negative only'\n        assert torch.equal(target**2, target), \\\n            'targets should be binary (0 or 1)'\n        if self.scores.numel() > 0:\n            assert target.size(1) == self.targets.size(1), \\\n                'dimensions for output should match previously added examples.'\n\n        # make sure storage is of sufficient size\n        if self.scores.storage().size() < self.scores.numel() + output.numel():\n            new_size = math.ceil(self.scores.storage().size() * 1.5)\n            new_weight_size = math.ceil(self.weights.storage().size() * 1.5)\n            self.scores.storage().resize_(int(new_size + output.numel()))\n            self.targets.storage().resize_(int(new_size + output.numel()))\n            if weight is not None:\n                self.weights.storage().resize_(int(new_weight_size + output.size(0)))\n\n        # store scores and targets\n        offset = self.scores.size(0) if self.scores.dim() > 0 else 0\n        self.scores.resize_(offset + output.size(0), output.size(1))\n        self.targets.resize_(offset + target.size(0), target.size(1))\n        self.scores.narrow(0, offset, output.size(0)).copy_(output)\n        self.targets.narrow(0, offset, target.size(0)).copy_(target)\n\n        if weight is not None:\n            self.weights.resize_(offset + weight.size(0))\n            self.weights.narrow(0, offset, weight.size(0)).copy_(weight)\n\n    def value(self):\n        \"\"\"Returns the model's average precision for each class\n\n        Return:\n            ap (FloatTensor): 1xK tensor, with avg precision for each class k\n        \"\"\"\n\n        if self.scores.numel() == 0:\n            return 0\n        ap = torch.zeros(self.scores.size(1))\n        if hasattr(torch, \"arange\"):\n            rg = torch.arange(1, self.scores.size(0) + 1).float()\n        else:\n            rg = torch.range(1, self.scores.size(0)).float()\n        if self.weights.numel() > 0:\n            weight = self.weights.new(self.weights.size())\n            weighted_truth = self.weights.new(self.weights.size())\n\n        # compute average precision for each class\n        for k in range(self.scores.size(1)):\n            # sort scores\n            scores = self.scores[:, k]\n            targets = self.targets[:, k]\n            _, sortind = torch.sort(scores, 0, True)\n            truth = targets[sortind]\n            if self.weights.numel() > 0:\n                weight = self.weights[sortind]\n                weighted_truth = truth.float() * weight\n                rg = weight.cumsum(0)\n\n            # compute true positive sums\n            if self.weights.numel() > 0:\n                tp = weighted_truth.cumsum(0)\n            else:\n                tp = truth.float().cumsum(0)\n\n            # compute precision curve\n            precision = tp.div(rg)\n\n            # compute average precision\n            ap[k] = precision[truth.byte()].sum() / max(truth.sum(), 1)\n        return ap\n", "path": "torchnet/meter/apmeter.py"}], "after_files": [{"content": "import math\nfrom . import meter\nimport torch\n\n\nclass APMeter(meter.Meter):\n    \"\"\"\n    The APMeter measures the average precision per class.\n\n    The APMeter is designed to operate on `NxK` Tensors `output` and\n    `target`, and optionally a `Nx1` Tensor weight where (1) the `output`\n    contains model output scores for `N` examples and `K` classes that ought to\n    be higher when the model is more convinced that the example should be\n    positively labeled, and smaller when the model believes the example should\n    be negatively labeled (for instance, the output of a sigmoid function); (2)\n    the `target` contains only values 0 (for negative examples) and 1\n    (for positive examples); and (3) the `weight` ( > 0) represents weight for\n    each sample.\n    \"\"\"\n\n    def __init__(self):\n        super(APMeter, self).__init__()\n        self.reset()\n\n    def reset(self):\n        \"\"\"Resets the meter with empty member variables\"\"\"\n        self.scores = torch.FloatTensor(torch.FloatStorage())\n        self.targets = torch.LongTensor(torch.LongStorage())\n        self.weights = torch.FloatTensor(torch.FloatStorage())\n\n    def add(self, output, target, weight=None):\n        \"\"\"\n        Args:\n            output (Tensor): NxK tensor that for each of the N examples\n                indicates the probability of the example belonging to each of\n                the K classes, according to the model. The probabilities should\n                sum to one over all classes\n            target (Tensor): binary NxK tensort that encodes which of the K\n                classes are associated with the N-th input\n                    (eg: a row [0, 1, 0, 1] indicates that the example is\n                         associated with classes 2 and 4)\n            weight (optional, Tensor): Nx1 tensor representing the weight for\n                each example (each weight > 0)\n        \"\"\"\n        if not torch.is_tensor(output):\n            output = torch.from_numpy(output)\n        if not torch.is_tensor(target):\n            target = torch.from_numpy(target)\n\n        if weight is not None:\n            if not torch.is_tensor(weight):\n                weight = torch.from_numpy(weight)\n            weight = weight.squeeze()\n        if output.dim() == 1:\n            output = output.view(-1, 1)\n        else:\n            assert output.dim() == 2, \\\n                'wrong output size (should be 1D or 2D with one column \\\n                per class)'\n        if target.dim() == 1:\n            target = target.view(-1, 1)\n        else:\n            assert target.dim() == 2, \\\n                'wrong target size (should be 1D or 2D with one column \\\n                per class)'\n        if weight is not None:\n            assert weight.dim() == 1, 'Weight dimension should be 1'\n            assert weight.numel() == target.size(0), \\\n                'Weight dimension 1 should be the same as that of target'\n            assert torch.min(weight) >= 0, 'Weight should be non-negative only'\n        assert torch.equal(target**2, target), \\\n            'targets should be binary (0 or 1)'\n        if self.scores.numel() > 0:\n            assert target.size(1) == self.targets.size(1), \\\n                'dimensions for output should match previously added examples.'\n\n        # make sure storage is of sufficient size\n        if self.scores.storage().size() < self.scores.numel() + output.numel():\n            new_size = math.ceil(self.scores.storage().size() * 1.5)\n            new_weight_size = math.ceil(self.weights.storage().size() * 1.5)\n            self.scores.storage().resize_(int(new_size + output.numel()))\n            self.targets.storage().resize_(int(new_size + output.numel()))\n            if weight is not None:\n                self.weights.storage().resize_(int(new_weight_size + output.size(0)))\n\n        # store scores and targets\n        offset = self.scores.size(0) if self.scores.dim() > 0 else 0\n        self.scores.resize_(offset + output.size(0), output.size(1))\n        self.targets.resize_(offset + target.size(0), target.size(1))\n        self.scores.narrow(0, offset, output.size(0)).copy_(output)\n        self.targets.narrow(0, offset, target.size(0)).copy_(target)\n\n        if weight is not None:\n            self.weights.resize_(offset + weight.size(0))\n            self.weights.narrow(0, offset, weight.size(0)).copy_(weight)\n\n    def value(self):\n        \"\"\"Returns the model's average precision for each class\n\n        Return:\n            ap (FloatTensor): 1xK tensor, with avg precision for each class k\n        \"\"\"\n\n        if self.scores.numel() == 0:\n            return 0\n        ap = torch.zeros(self.scores.size(1))\n        if hasattr(torch, \"arange\"):\n            rg = torch.arange(1, self.scores.size(0) + 1).float()\n        else:\n            rg = torch.range(1, self.scores.size(0)).float()\n        if self.weights.numel() > 0:\n            weight = self.weights.new(self.weights.size())\n            weighted_truth = self.weights.new(self.weights.size())\n\n        # compute average precision for each class\n        for k in range(self.scores.size(1)):\n            # sort scores\n            scores = self.scores[:, k]\n            targets = self.targets[:, k]\n            _, sortind = torch.sort(scores, 0, True)\n            truth = targets[sortind]\n            if self.weights.numel() > 0:\n                weight = self.weights[sortind]\n                weighted_truth = truth.float() * weight\n                rg = weight.cumsum(0)\n\n            # compute true positive sums\n            if self.weights.numel() > 0:\n                tp = weighted_truth.cumsum(0)\n            else:\n                tp = truth.float().cumsum(0)\n\n            # compute precision curve\n            precision = tp.div(rg)\n\n            # compute average precision\n            ap[k] = precision[truth.byte()].sum() / max(float(truth.sum()), 1)\n        return ap\n", "path": "torchnet/meter/apmeter.py"}]}