code: def _sacreformat(refs, preds):
      """Format refs and preds for sacrebleu corpus calculation. It is very particular"""
      # Sacrebleu expects (List[str], List[List[str])
      #   e.g. sacrebleu.corpus_bleu([pred_t], [[ref1_stream], [ref2_stream], ...])
  
      # Note [ref1_stream] is the first reference for each pred.
      # So lists are size N and (M, N) for N preds and M possible refs for each pred
      # This is a different order of dimensions that I would expect
  
      # We expect refs to be List[str] or List[List[str]], the outer list corresponding to preds
      # Must become List[List[str]] with the inner list corresponding to preds
      if not is_non_str_iterable(refs):
          refs = list(refs)
      if not is_non_str_iterable(refs[0]):
          refs = [[ref] for ref in refs]
      refs = list(zip(*refs))
      # Note the number of refs in each ref list much match the number of preds
  
      # We expect preds to be List[str] or List[List[str]]. Must become List[str]
      if not is_non_str_iterable(preds):
          preds = list(preds)
      if is_non_str_iterable(preds[0]):
          assert (
              len(preds[0]) == 1
          ), f"Pred must be a str, was {preds[0]}"
          preds = [pred[0] for pred in preds]
  
      return refs, preds
  
imports: import math
  from collections.abc import Iterable
  import numpy
  import sacrebleu
  import sklearn.metrics
  import random
  from collections import defaultdict
label_desc: Use image node_id 21 for calling a global function with example usage: _sacreformat(refs, preds) and returns: refs,  preds