We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
NLTK being loaded on image classifcation
## 🐛 Bug

<!-- A clear and concise description of what the bug is. -->

### To Reproduce


```python
from flash.data import labels_from_csv
from flash.vision import ImageClassificationData
from flash.vision import ImageClassifier
from flash import Trainer
```
<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->

[nltk_data] Error loading punkt: <urlopen error [Errno -3] Temporary
[nltk_data]     failure in name resolution>



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `flash/text/seq2seq/summarization/metric.py`
Content:
```
1 # Copyright The PyTorch Lightning team.
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 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 from typing import Dict, List, Tuple
15 
16 import numpy as np
17 from rouge_score import rouge_scorer, scoring
18 from rouge_score.scoring import AggregateScore, Score
19 from torch import tensor
20 from torchmetrics import Metric
21 
22 from flash.text.seq2seq.summarization.utils import add_newline_to_end_of_each_sentence
23 
24 
25 class RougeMetric(Metric):
26     """
27     Metric used for automatic summarization. https://www.aclweb.org/anthology/W04-1013/
28 
29     Example:
30 
31         >>> target = "Is your name John".split()
32         >>> preds = "My name is John".split()
33         >>> rouge = RougeMetric()
34         >>> from pprint import pprint
35         >>> pprint(rouge(preds, target))  # doctest: +NORMALIZE_WHITESPACE
36         {'rouge1_fmeasure': 0.25,
37          'rouge1_precision': 0.25,
38          'rouge1_recall': 0.25,
39          'rouge2_fmeasure': 0.0,
40          'rouge2_precision': 0.0,
41          'rouge2_recall': 0.0,
42          'rougeL_fmeasure': 0.25,
43          'rougeL_precision': 0.25,
44          'rougeL_recall': 0.25,
45          'rougeLsum_fmeasure': 0.25,
46          'rougeLsum_precision': 0.25,
47          'rougeLsum_recall': 0.25}
48     """
49 
50     def __init__(
51         self,
52         rouge_newline_sep: bool = False,
53         use_stemmer: bool = False,
54         rouge_keys: Tuple[str] = ("rouge1", "rouge2", "rougeL", "rougeLsum"),
55     ):
56         super().__init__()
57         self.rouge_newline_sep = rouge_newline_sep
58         self.rouge_keys = rouge_keys
59         self.use_stemmer = use_stemmer
60         self.aggregator = RougeBatchAggregator()
61         self.scorer = rouge_scorer.RougeScorer(rouge_keys, use_stemmer=self.use_stemmer)
62 
63         for key in rouge_keys:
64             self.add_state(key, [])
65 
66     def update(self, pred_lns: List[str], tgt_lns: List[str]):
67         for pred, tgt in zip(pred_lns, tgt_lns):
68             # rougeLsum expects "\n" separated sentences within a summary
69             if self.rouge_newline_sep:
70                 pred = add_newline_to_end_of_each_sentence(pred)
71                 tgt = add_newline_to_end_of_each_sentence(tgt)
72             results = self.scorer.score(pred, tgt)
73             for key, score in results.items():
74                 score = tensor([score.precision, score.recall, score.fmeasure])
75                 getattr(self, key).append(score)
76 
77     def compute(self) -> Dict[str, float]:
78         scores = {key: getattr(self, key) for key in self.rouge_keys}
79         self.aggregator.add_scores(scores)
80         result = self.aggregator.aggregate()
81         return format_rouge_results(result)
82 
83     def __hash__(self):
84         # override to hash list objects.
85         # this is a bug in the upstream pytorch release.
86         hash_vals = [self.__class__.__name__]
87 
88         for key in self._defaults.keys():
89             value = getattr(self, key)
90             if isinstance(value, list):
91                 value = tuple(value)
92             hash_vals.append(value)
93 
94         return hash(tuple(hash_vals))
95 
96 
97 class RougeBatchAggregator(scoring.BootstrapAggregator):
98     """
99     Aggregates rouge scores and provides confidence intervals.
100     """
101 
102     def aggregate(self):
103         """
104         Override function to wrap the final results in `Score` objects.
105         This is due to the scores being replaced with a list of torch tensors.
106         """
107         result = {}
108         for score_type, scores in self._scores.items():
109             # Stack scores into a 2-d matrix of (sample, measure).
110             score_matrix = np.vstack(tuple(scores))
111             # Percentiles are returned as (interval, measure).
112             percentiles = self._bootstrap_resample(score_matrix)
113             # Extract the three intervals (low, mid, high).
114             intervals = tuple((Score(*percentiles[j, :]) for j in range(3)))
115             result[score_type] = AggregateScore(low=intervals[0], mid=intervals[1], high=intervals[2])
116         return result
117 
118     def add_scores(self, scores):
119         self._scores = scores
120 
121 
122 def format_rouge_results(result: Dict[str, AggregateScore], decimal_places: int = 4) -> Dict[str, float]:
123     flattened_result = {}
124     for rouge_key, rouge_aggregate_score in result.items():
125         for stat in ["precision", "recall", "fmeasure"]:
126             mid = rouge_aggregate_score.mid
127             score = round(getattr(mid, stat), decimal_places)
128             flattened_result[f"{rouge_key}_{stat}"] = score
129     return flattened_result
130
```
--- 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/flash/text/seq2seq/summarization/metric.py b/flash/text/seq2seq/summarization/metric.py
--- a/flash/text/seq2seq/summarization/metric.py
+++ b/flash/text/seq2seq/summarization/metric.py
@@ -19,7 +19,7 @@
 from torch import tensor
 from torchmetrics import Metric
 
-from flash.text.seq2seq.summarization.utils import add_newline_to_end_of_each_sentence
+from flash.text.seq2seq import summarization
 
 
 class RougeMetric(Metric):
@@ -67,8 +67,8 @@
         for pred, tgt in zip(pred_lns, tgt_lns):
             # rougeLsum expects "\n" separated sentences within a summary
             if self.rouge_newline_sep:
-                pred = add_newline_to_end_of_each_sentence(pred)
-                tgt = add_newline_to_end_of_each_sentence(tgt)
+                pred = summarization.utils.add_newline_to_end_of_each_sentence(pred)
+                tgt = summarization.utils.add_newline_to_end_of_each_sentence(tgt)
             results = self.scorer.score(pred, tgt)
             for key, score in results.items():
                 score = tensor([score.precision, score.recall, score.fmeasure])

{"golden_diff": "diff --git a/flash/text/seq2seq/summarization/metric.py b/flash/text/seq2seq/summarization/metric.py\n--- a/flash/text/seq2seq/summarization/metric.py\n+++ b/flash/text/seq2seq/summarization/metric.py\n@@ -19,7 +19,7 @@\n from torch import tensor\n from torchmetrics import Metric\n \n-from flash.text.seq2seq.summarization.utils import add_newline_to_end_of_each_sentence\n+from flash.text.seq2seq import summarization\n \n \n class RougeMetric(Metric):\n@@ -67,8 +67,8 @@\n         for pred, tgt in zip(pred_lns, tgt_lns):\n             # rougeLsum expects \"\\n\" separated sentences within a summary\n             if self.rouge_newline_sep:\n-                pred = add_newline_to_end_of_each_sentence(pred)\n-                tgt = add_newline_to_end_of_each_sentence(tgt)\n+                pred = summarization.utils.add_newline_to_end_of_each_sentence(pred)\n+                tgt = summarization.utils.add_newline_to_end_of_each_sentence(tgt)\n             results = self.scorer.score(pred, tgt)\n             for key, score in results.items():\n                 score = tensor([score.precision, score.recall, score.fmeasure])\n", "issue": "NLTK being loaded on image classifcation\n## \ud83d\udc1b Bug\r\n\r\n<!-- A clear and concise description of what the bug is. -->\r\n\r\n### To Reproduce\r\n\r\n\r\n```python\r\nfrom flash.data import labels_from_csv\r\nfrom flash.vision import ImageClassificationData\r\nfrom flash.vision import ImageClassifier\r\nfrom flash import Trainer\r\n```\r\n<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->\r\n\r\n[nltk_data] Error loading punkt: <urlopen error [Errno -3] Temporary\r\n[nltk_data]     failure in name resolution>\r\n\r\n\n", "before_files": [{"content": "# Copyright The PyTorch Lightning team.\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# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nfrom typing import Dict, List, Tuple\n\nimport numpy as np\nfrom rouge_score import rouge_scorer, scoring\nfrom rouge_score.scoring import AggregateScore, Score\nfrom torch import tensor\nfrom torchmetrics import Metric\n\nfrom flash.text.seq2seq.summarization.utils import add_newline_to_end_of_each_sentence\n\n\nclass RougeMetric(Metric):\n    \"\"\"\n    Metric used for automatic summarization. https://www.aclweb.org/anthology/W04-1013/\n\n    Example:\n\n        >>> target = \"Is your name John\".split()\n        >>> preds = \"My name is John\".split()\n        >>> rouge = RougeMetric()\n        >>> from pprint import pprint\n        >>> pprint(rouge(preds, target))  # doctest: +NORMALIZE_WHITESPACE\n        {'rouge1_fmeasure': 0.25,\n         'rouge1_precision': 0.25,\n         'rouge1_recall': 0.25,\n         'rouge2_fmeasure': 0.0,\n         'rouge2_precision': 0.0,\n         'rouge2_recall': 0.0,\n         'rougeL_fmeasure': 0.25,\n         'rougeL_precision': 0.25,\n         'rougeL_recall': 0.25,\n         'rougeLsum_fmeasure': 0.25,\n         'rougeLsum_precision': 0.25,\n         'rougeLsum_recall': 0.25}\n    \"\"\"\n\n    def __init__(\n        self,\n        rouge_newline_sep: bool = False,\n        use_stemmer: bool = False,\n        rouge_keys: Tuple[str] = (\"rouge1\", \"rouge2\", \"rougeL\", \"rougeLsum\"),\n    ):\n        super().__init__()\n        self.rouge_newline_sep = rouge_newline_sep\n        self.rouge_keys = rouge_keys\n        self.use_stemmer = use_stemmer\n        self.aggregator = RougeBatchAggregator()\n        self.scorer = rouge_scorer.RougeScorer(rouge_keys, use_stemmer=self.use_stemmer)\n\n        for key in rouge_keys:\n            self.add_state(key, [])\n\n    def update(self, pred_lns: List[str], tgt_lns: List[str]):\n        for pred, tgt in zip(pred_lns, tgt_lns):\n            # rougeLsum expects \"\\n\" separated sentences within a summary\n            if self.rouge_newline_sep:\n                pred = add_newline_to_end_of_each_sentence(pred)\n                tgt = add_newline_to_end_of_each_sentence(tgt)\n            results = self.scorer.score(pred, tgt)\n            for key, score in results.items():\n                score = tensor([score.precision, score.recall, score.fmeasure])\n                getattr(self, key).append(score)\n\n    def compute(self) -> Dict[str, float]:\n        scores = {key: getattr(self, key) for key in self.rouge_keys}\n        self.aggregator.add_scores(scores)\n        result = self.aggregator.aggregate()\n        return format_rouge_results(result)\n\n    def __hash__(self):\n        # override to hash list objects.\n        # this is a bug in the upstream pytorch release.\n        hash_vals = [self.__class__.__name__]\n\n        for key in self._defaults.keys():\n            value = getattr(self, key)\n            if isinstance(value, list):\n                value = tuple(value)\n            hash_vals.append(value)\n\n        return hash(tuple(hash_vals))\n\n\nclass RougeBatchAggregator(scoring.BootstrapAggregator):\n    \"\"\"\n    Aggregates rouge scores and provides confidence intervals.\n    \"\"\"\n\n    def aggregate(self):\n        \"\"\"\n        Override function to wrap the final results in `Score` objects.\n        This is due to the scores being replaced with a list of torch tensors.\n        \"\"\"\n        result = {}\n        for score_type, scores in self._scores.items():\n            # Stack scores into a 2-d matrix of (sample, measure).\n            score_matrix = np.vstack(tuple(scores))\n            # Percentiles are returned as (interval, measure).\n            percentiles = self._bootstrap_resample(score_matrix)\n            # Extract the three intervals (low, mid, high).\n            intervals = tuple((Score(*percentiles[j, :]) for j in range(3)))\n            result[score_type] = AggregateScore(low=intervals[0], mid=intervals[1], high=intervals[2])\n        return result\n\n    def add_scores(self, scores):\n        self._scores = scores\n\n\ndef format_rouge_results(result: Dict[str, AggregateScore], decimal_places: int = 4) -> Dict[str, float]:\n    flattened_result = {}\n    for rouge_key, rouge_aggregate_score in result.items():\n        for stat in [\"precision\", \"recall\", \"fmeasure\"]:\n            mid = rouge_aggregate_score.mid\n            score = round(getattr(mid, stat), decimal_places)\n            flattened_result[f\"{rouge_key}_{stat}\"] = score\n    return flattened_result\n", "path": "flash/text/seq2seq/summarization/metric.py"}], "after_files": [{"content": "# Copyright The PyTorch Lightning team.\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# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\nfrom typing import Dict, List, Tuple\n\nimport numpy as np\nfrom rouge_score import rouge_scorer, scoring\nfrom rouge_score.scoring import AggregateScore, Score\nfrom torch import tensor\nfrom torchmetrics import Metric\n\nfrom flash.text.seq2seq import summarization\n\n\nclass RougeMetric(Metric):\n    \"\"\"\n    Metric used for automatic summarization. https://www.aclweb.org/anthology/W04-1013/\n\n    Example:\n\n        >>> target = \"Is your name John\".split()\n        >>> preds = \"My name is John\".split()\n        >>> rouge = RougeMetric()\n        >>> from pprint import pprint\n        >>> pprint(rouge(preds, target))  # doctest: +NORMALIZE_WHITESPACE\n        {'rouge1_fmeasure': 0.25,\n         'rouge1_precision': 0.25,\n         'rouge1_recall': 0.25,\n         'rouge2_fmeasure': 0.0,\n         'rouge2_precision': 0.0,\n         'rouge2_recall': 0.0,\n         'rougeL_fmeasure': 0.25,\n         'rougeL_precision': 0.25,\n         'rougeL_recall': 0.25,\n         'rougeLsum_fmeasure': 0.25,\n         'rougeLsum_precision': 0.25,\n         'rougeLsum_recall': 0.25}\n    \"\"\"\n\n    def __init__(\n        self,\n        rouge_newline_sep: bool = False,\n        use_stemmer: bool = False,\n        rouge_keys: Tuple[str] = (\"rouge1\", \"rouge2\", \"rougeL\", \"rougeLsum\"),\n    ):\n        super().__init__()\n        self.rouge_newline_sep = rouge_newline_sep\n        self.rouge_keys = rouge_keys\n        self.use_stemmer = use_stemmer\n        self.aggregator = RougeBatchAggregator()\n        self.scorer = rouge_scorer.RougeScorer(rouge_keys, use_stemmer=self.use_stemmer)\n\n        for key in rouge_keys:\n            self.add_state(key, [])\n\n    def update(self, pred_lns: List[str], tgt_lns: List[str]):\n        for pred, tgt in zip(pred_lns, tgt_lns):\n            # rougeLsum expects \"\\n\" separated sentences within a summary\n            if self.rouge_newline_sep:\n                pred = summarization.utils.add_newline_to_end_of_each_sentence(pred)\n                tgt = summarization.utils.add_newline_to_end_of_each_sentence(tgt)\n            results = self.scorer.score(pred, tgt)\n            for key, score in results.items():\n                score = tensor([score.precision, score.recall, score.fmeasure])\n                getattr(self, key).append(score)\n\n    def compute(self) -> Dict[str, float]:\n        scores = {key: getattr(self, key) for key in self.rouge_keys}\n        self.aggregator.add_scores(scores)\n        result = self.aggregator.aggregate()\n        return format_rouge_results(result)\n\n    def __hash__(self):\n        # override to hash list objects.\n        # this is a bug in the upstream pytorch release.\n        hash_vals = [self.__class__.__name__]\n\n        for key in self._defaults.keys():\n            value = getattr(self, key)\n            if isinstance(value, list):\n                value = tuple(value)\n            hash_vals.append(value)\n\n        return hash(tuple(hash_vals))\n\n\nclass RougeBatchAggregator(scoring.BootstrapAggregator):\n    \"\"\"\n    Aggregates rouge scores and provides confidence intervals.\n    \"\"\"\n\n    def aggregate(self):\n        \"\"\"\n        Override function to wrap the final results in `Score` objects.\n        This is due to the scores being replaced with a list of torch tensors.\n        \"\"\"\n        result = {}\n        for score_type, scores in self._scores.items():\n            # Stack scores into a 2-d matrix of (sample, measure).\n            score_matrix = np.vstack(tuple(scores))\n            # Percentiles are returned as (interval, measure).\n            percentiles = self._bootstrap_resample(score_matrix)\n            # Extract the three intervals (low, mid, high).\n            intervals = tuple((Score(*percentiles[j, :]) for j in range(3)))\n            result[score_type] = AggregateScore(low=intervals[0], mid=intervals[1], high=intervals[2])\n        return result\n\n    def add_scores(self, scores):\n        self._scores = scores\n\n\ndef format_rouge_results(result: Dict[str, AggregateScore], decimal_places: int = 4) -> Dict[str, float]:\n    flattened_result = {}\n    for rouge_key, rouge_aggregate_score in result.items():\n        for stat in [\"precision\", \"recall\", \"fmeasure\"]:\n            mid = rouge_aggregate_score.mid\n            score = round(getattr(mid, stat), decimal_places)\n            flattened_result[f\"{rouge_key}_{stat}\"] = score\n    return flattened_result\n", "path": "flash/text/seq2seq/summarization/metric.py"}]}