prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  The type of `n_gram` is mislabeled as bool, which should be int type.
  ## 🐛 Bug
  
  In Translation Task:
  The type of `n_gram` is mislabeled as bool, which should be int type.
  
  ### To Reproduce
  
  <!-- If you have a code sample, error messages, stack traces, please provide it here as well -->
  ```
  flash translation from_hf_datasets --help
  ```
  The error raised:
  ```
  translation: error: Configuration check failed :: Parser key "model.n_gram": Expected a <class 'bool'> but got "4"
  ```
  
  
  --- 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/translation/model.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 Any, Dict, Optional, Union
  15 
  16 from torchmetrics import BLEUScore
  17 
  18 from flash.core.utilities.imports import _TM_GREATER_EQUAL_0_7_0
  19 from flash.core.utilities.types import LOSS_FN_TYPE, LR_SCHEDULER_TYPE, METRICS_TYPE, OPTIMIZER_TYPE
  20 from flash.text.seq2seq.core.model import Seq2SeqTask
  21 
  22 
  23 class TranslationTask(Seq2SeqTask):
  24     """The ``TranslationTask`` is a :class:`~flash.Task` for Seq2Seq text translation. For more details, see
  25     :ref:`translation`.
  26 
  27     You can change the backbone to any translation model from `HuggingFace/transformers
  28     <https://huggingface.co/models?filter=pytorch&pipeline_tag=translation>`__ using the ``backbone`` argument.
  29 
  30     Args:
  31         backbone: backbone model to use for the task.
  32         max_source_length: The maximum length to pad / truncate input sequences to.
  33         max_target_length: The maximum length to pad / truncate target sequences to.
  34         padding: The type of padding to apply. One of: "longest" or ``True``, "max_length", "do_not_pad" or
  35             ``False``.
  36         loss_fn: Loss function for training.
  37         optimizer: Optimizer to use for training.
  38         lr_scheduler: The LR scheduler to use during training.
  39         metrics: Metrics to compute for training and evaluation. Defauls to calculating the BLEU metric.
  40             Changing this argument currently has no effect.
  41         learning_rate: Learning rate to use for training, defaults to `1e-5`
  42         num_beams: Number of beams to use in validation when generating predictions. Defaults to `4`
  43         n_gram: Maximum n_grams to use in metric calculation. Defaults to `4`
  44         smooth: Apply smoothing in BLEU calculation. Defaults to `True`
  45         enable_ort: Enable Torch ONNX Runtime Optimization: https://onnxruntime.ai/docs/#onnx-runtime-for-training
  46     """
  47 
  48     def __init__(
  49         self,
  50         backbone: str = "t5-small",
  51         tokenizer_kwargs: Optional[Dict[str, Any]] = None,
  52         max_source_length: int = 128,
  53         max_target_length: int = 128,
  54         padding: Union[str, bool] = "max_length",
  55         loss_fn: LOSS_FN_TYPE = None,
  56         optimizer: OPTIMIZER_TYPE = "Adam",
  57         lr_scheduler: LR_SCHEDULER_TYPE = None,
  58         metrics: METRICS_TYPE = None,
  59         learning_rate: Optional[float] = None,
  60         num_beams: Optional[int] = 4,
  61         n_gram: bool = 4,
  62         smooth: bool = True,
  63         enable_ort: bool = False,
  64     ):
  65         self.save_hyperparameters()
  66         super().__init__(
  67             backbone=backbone,
  68             tokenizer_kwargs=tokenizer_kwargs,
  69             max_source_length=max_source_length,
  70             max_target_length=max_target_length,
  71             padding=padding,
  72             loss_fn=loss_fn,
  73             optimizer=optimizer,
  74             lr_scheduler=lr_scheduler,
  75             metrics=metrics,
  76             learning_rate=learning_rate,
  77             num_beams=num_beams,
  78             enable_ort=enable_ort,
  79         )
  80         self.bleu = BLEUScore(
  81             n_gram=n_gram,
  82             smooth=smooth,
  83         )
  84 
  85     @property
  86     def task(self) -> str:
  87         return "translation"
  88 
  89     def compute_metrics(self, generated_tokens, batch, prefix):
  90         reference_corpus = self.decode(batch["labels"])
  91         # wrap targets in list as score expects a list of potential references
  92         reference_corpus = [[reference] for reference in reference_corpus]
  93 
  94         translate_corpus = self.decode(generated_tokens)
  95         translate_corpus = [line for line in translate_corpus]
  96 
  97         if _TM_GREATER_EQUAL_0_7_0:
  98             result = self.bleu(translate_corpus, reference_corpus)
  99         else:
  100             result = self.bleu(reference_corpus, translate_corpus)
  101         self.log(f"{prefix}_bleu_score", result, on_step=False, on_epoch=True, prog_bar=True)
  102
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/flash/text/seq2seq/translation/model.py b/flash/text/seq2seq/translation/model.py
  --- a/flash/text/seq2seq/translation/model.py
  +++ b/flash/text/seq2seq/translation/model.py
  @@ -58,7 +58,7 @@
           metrics: METRICS_TYPE = None,
           learning_rate: Optional[float] = None,
           num_beams: Optional[int] = 4,
  -        n_gram: bool = 4,
  +        n_gram: int = 4,
           smooth: bool = True,
           enable_ort: bool = False,
       ):
  
verification_info: {"golden_diff": "diff --git a/flash/text/seq2seq/translation/model.py b/flash/text/seq2seq/translation/model.py\n--- a/flash/text/seq2seq/translation/model.py\n+++ b/flash/text/seq2seq/translation/model.py\n@@ -58,7 +58,7 @@\n         metrics: METRICS_TYPE = None,\n         learning_rate: Optional[float] = None,\n         num_beams: Optional[int] = 4,\n-        n_gram: bool = 4,\n+        n_gram: int = 4,\n         smooth: bool = True,\n         enable_ort: bool = False,\n     ):\n", "issue": "The type of `n_gram` is mislabeled as bool, which should be int type.\n## \ud83d\udc1b Bug\r\n\r\nIn Translation Task:\r\nThe type of `n_gram` is mislabeled as bool, which should be int type.\r\n\r\n### To Reproduce\r\n\r\n<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->\r\n```\r\nflash translation from_hf_datasets --help\r\n```\r\nThe error raised:\r\n```\r\ntranslation: error: Configuration check failed :: Parser key \"model.n_gram\": Expected a <class 'bool'> but got \"4\"\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 Any, Dict, Optional, Union\n\nfrom torchmetrics import BLEUScore\n\nfrom flash.core.utilities.imports import _TM_GREATER_EQUAL_0_7_0\nfrom flash.core.utilities.types import LOSS_FN_TYPE, LR_SCHEDULER_TYPE, METRICS_TYPE, OPTIMIZER_TYPE\nfrom flash.text.seq2seq.core.model import Seq2SeqTask\n\n\nclass TranslationTask(Seq2SeqTask):\n    \"\"\"The ``TranslationTask`` is a :class:`~flash.Task` for Seq2Seq text translation. For more details, see\n    :ref:`translation`.\n\n    You can change the backbone to any translation model from `HuggingFace/transformers\n    <https://huggingface.co/models?filter=pytorch&pipeline_tag=translation>`__ using the ``backbone`` argument.\n\n    Args:\n        backbone: backbone model to use for the task.\n        max_source_length: The maximum length to pad / truncate input sequences to.\n        max_target_length: The maximum length to pad / truncate target sequences to.\n        padding: The type of padding to apply. One of: \"longest\" or ``True``, \"max_length\", \"do_not_pad\" or\n            ``False``.\n        loss_fn: Loss function for training.\n        optimizer: Optimizer to use for training.\n        lr_scheduler: The LR scheduler to use during training.\n        metrics: Metrics to compute for training and evaluation. Defauls to calculating the BLEU metric.\n            Changing this argument currently has no effect.\n        learning_rate: Learning rate to use for training, defaults to `1e-5`\n        num_beams: Number of beams to use in validation when generating predictions. Defaults to `4`\n        n_gram: Maximum n_grams to use in metric calculation. Defaults to `4`\n        smooth: Apply smoothing in BLEU calculation. Defaults to `True`\n        enable_ort: Enable Torch ONNX Runtime Optimization: https://onnxruntime.ai/docs/#onnx-runtime-for-training\n    \"\"\"\n\n    def __init__(\n        self,\n        backbone: str = \"t5-small\",\n        tokenizer_kwargs: Optional[Dict[str, Any]] = None,\n        max_source_length: int = 128,\n        max_target_length: int = 128,\n        padding: Union[str, bool] = \"max_length\",\n        loss_fn: LOSS_FN_TYPE = None,\n        optimizer: OPTIMIZER_TYPE = \"Adam\",\n        lr_scheduler: LR_SCHEDULER_TYPE = None,\n        metrics: METRICS_TYPE = None,\n        learning_rate: Optional[float] = None,\n        num_beams: Optional[int] = 4,\n        n_gram: bool = 4,\n        smooth: bool = True,\n        enable_ort: bool = False,\n    ):\n        self.save_hyperparameters()\n        super().__init__(\n            backbone=backbone,\n            tokenizer_kwargs=tokenizer_kwargs,\n            max_source_length=max_source_length,\n            max_target_length=max_target_length,\n            padding=padding,\n            loss_fn=loss_fn,\n            optimizer=optimizer,\n            lr_scheduler=lr_scheduler,\n            metrics=metrics,\n            learning_rate=learning_rate,\n            num_beams=num_beams,\n            enable_ort=enable_ort,\n        )\n        self.bleu = BLEUScore(\n            n_gram=n_gram,\n            smooth=smooth,\n        )\n\n    @property\n    def task(self) -> str:\n        return \"translation\"\n\n    def compute_metrics(self, generated_tokens, batch, prefix):\n        reference_corpus = self.decode(batch[\"labels\"])\n        # wrap targets in list as score expects a list of potential references\n        reference_corpus = [[reference] for reference in reference_corpus]\n\n        translate_corpus = self.decode(generated_tokens)\n        translate_corpus = [line for line in translate_corpus]\n\n        if _TM_GREATER_EQUAL_0_7_0:\n            result = self.bleu(translate_corpus, reference_corpus)\n        else:\n            result = self.bleu(reference_corpus, translate_corpus)\n        self.log(f\"{prefix}_bleu_score\", result, on_step=False, on_epoch=True, prog_bar=True)\n", "path": "flash/text/seq2seq/translation/model.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 Any, Dict, Optional, Union\n\nfrom torchmetrics import BLEUScore\n\nfrom flash.core.utilities.imports import _TM_GREATER_EQUAL_0_7_0\nfrom flash.core.utilities.types import LOSS_FN_TYPE, LR_SCHEDULER_TYPE, METRICS_TYPE, OPTIMIZER_TYPE\nfrom flash.text.seq2seq.core.model import Seq2SeqTask\n\n\nclass TranslationTask(Seq2SeqTask):\n    \"\"\"The ``TranslationTask`` is a :class:`~flash.Task` for Seq2Seq text translation. For more details, see\n    :ref:`translation`.\n\n    You can change the backbone to any translation model from `HuggingFace/transformers\n    <https://huggingface.co/models?filter=pytorch&pipeline_tag=translation>`__ using the ``backbone`` argument.\n\n    Args:\n        backbone: backbone model to use for the task.\n        max_source_length: The maximum length to pad / truncate input sequences to.\n        max_target_length: The maximum length to pad / truncate target sequences to.\n        padding: The type of padding to apply. One of: \"longest\" or ``True``, \"max_length\", \"do_not_pad\" or\n            ``False``.\n        loss_fn: Loss function for training.\n        optimizer: Optimizer to use for training.\n        lr_scheduler: The LR scheduler to use during training.\n        metrics: Metrics to compute for training and evaluation. Defauls to calculating the BLEU metric.\n            Changing this argument currently has no effect.\n        learning_rate: Learning rate to use for training, defaults to `1e-5`\n        num_beams: Number of beams to use in validation when generating predictions. Defaults to `4`\n        n_gram: Maximum n_grams to use in metric calculation. Defaults to `4`\n        smooth: Apply smoothing in BLEU calculation. Defaults to `True`\n        enable_ort: Enable Torch ONNX Runtime Optimization: https://onnxruntime.ai/docs/#onnx-runtime-for-training\n    \"\"\"\n\n    def __init__(\n        self,\n        backbone: str = \"t5-small\",\n        tokenizer_kwargs: Optional[Dict[str, Any]] = None,\n        max_source_length: int = 128,\n        max_target_length: int = 128,\n        padding: Union[str, bool] = \"max_length\",\n        loss_fn: LOSS_FN_TYPE = None,\n        optimizer: OPTIMIZER_TYPE = \"Adam\",\n        lr_scheduler: LR_SCHEDULER_TYPE = None,\n        metrics: METRICS_TYPE = None,\n        learning_rate: Optional[float] = None,\n        num_beams: Optional[int] = 4,\n        n_gram: int = 4,\n        smooth: bool = True,\n        enable_ort: bool = False,\n    ):\n        self.save_hyperparameters()\n        super().__init__(\n            backbone=backbone,\n            tokenizer_kwargs=tokenizer_kwargs,\n            max_source_length=max_source_length,\n            max_target_length=max_target_length,\n            padding=padding,\n            loss_fn=loss_fn,\n            optimizer=optimizer,\n            lr_scheduler=lr_scheduler,\n            metrics=metrics,\n            learning_rate=learning_rate,\n            num_beams=num_beams,\n            enable_ort=enable_ort,\n        )\n        self.bleu = BLEUScore(\n            n_gram=n_gram,\n            smooth=smooth,\n        )\n\n    @property\n    def task(self) -> str:\n        return \"translation\"\n\n    def compute_metrics(self, generated_tokens, batch, prefix):\n        reference_corpus = self.decode(batch[\"labels\"])\n        # wrap targets in list as score expects a list of potential references\n        reference_corpus = [[reference] for reference in reference_corpus]\n\n        translate_corpus = self.decode(generated_tokens)\n        translate_corpus = [line for line in translate_corpus]\n\n        if _TM_GREATER_EQUAL_0_7_0:\n            result = self.bleu(translate_corpus, reference_corpus)\n        else:\n            result = self.bleu(reference_corpus, translate_corpus)\n        self.log(f\"{prefix}_bleu_score\", result, on_step=False, on_epoch=True, prog_bar=True)\n", "path": "flash/text/seq2seq/translation/model.py"}]}