code: def bleu(
      preds,
      labels,
      smooth_method="exp",
      smooth_value=None,
      force=False,
      lowercase=False,
      tokenize=None,
      use_effective_order=False,
  ):
      # xtreme-s can only have one label
      labels = [[label] for label in labels]
      preds = list(preds)
      try:
          import sacrebleu as scb
      except ImportError:
          raise ValueError(
              "sacrebleu has to be installed in order to apply the bleu metric for covost2."
              "You can install it via `pip install sacrebleu`."
          )
  
      if version.parse(scb.__version__) < version.parse("1.4.12"):
          raise ImportWarning(
              "To use `sacrebleu`, the module `sacrebleu>=1.4.12` is required, and the current version of `sacrebleu` doesn't match this condition.\n"
              'You can install it with `pip install "sacrebleu>=1.4.12"`.'
          )
  
      references_per_prediction = len(labels[0])
      if any(len(refs) != references_per_prediction for refs in labels):
          raise ValueError(
              "Sacrebleu requires the same number of references for each prediction"
          )
      transformed_references = [
          [refs[i] for refs in labels]
          for i in range(references_per_prediction)
      ]
      output = scb.corpus_bleu(
          preds,
          transformed_references,
          smooth_method=smooth_method,
          smooth_value=smooth_value,
          force=force,
          lowercase=lowercase,
          use_effective_order=use_effective_order,
          **({"tokenize": tokenize} if tokenize else {}),
      )
      return {"bleu": output.score}
  
file_path: datasets/metrics/xtreme_s/xtreme_s.py
imports: from typing import List
  from packaging import version
  from sklearn.metrics import f1_score
  import datasets
  from datasets.config import PY_VERSION
label_desc: Use image node_id 3 for calling a global function with example usage: bleu(preds, labels, smooth_method, smooth_value, force, lowercase, tokenize, use_effective_order) and returns: dict