code: def span_squad(targets, predictions):
      """Computes SQuAD metrics for span prediction tasks.
  
      Uses qa metric function to compute EM and F1 score.
  
      Args:
        targets: list of dict of answers (list of strings) and context (string)
        predictions: list of strings, each string is contains the space tokenized
          ids in the format: "start: 3 end: 6"
  
      Returns:
        dict with score_key: squad score across all targets and predictions
      """
      assert len(targets) == len(predictions)
  
      def space_tok(s):
          return re.sub(r"\W", " ", s).split()
  
      def get_answer_text_from_context(context, answer_tokens):
          """Find the answer in the context given the answer tokens."""
          # In the initial training iterations, the model can output garbage.
          # Returning an empty string in such cases.
          if len(answer_tokens) < 4:
              return ""
  
          # Model sometimes predicts words instead of numbers in the answer. Return
          # an empty string in that case.
          try:
              start_index = int(answer_tokens[1])
              end_index = int(answer_tokens[3])
          except ValueError:
              return ""
  
          return " ".join(context[start_index : end_index + 1])
  
      contexts = [space_tok(t["context"]) for t in targets]
      answers = [t["answers"] for t in targets]
  
      predictions = [space_tok(p) for p in predictions]
      final_predictions = [
          get_answer_text_from_context(c, p)
          for c, p in zip(contexts, predictions)
      ]
  
      return squad(answers, final_predictions)
  
imports: import collections
  import itertools
  import re
  import string
  from typing import Any, Dict, Mapping, Optional, Sequence, Tuple, Union
  from absl import logging
  import editdistance
  import flax
  import jax.numpy
  import numpy
  import sacrebleu
  import scipy.stats
  import seqio
  import sklearn.metrics
  from t5.evaluation import qa_utils
  import tensorflow.compat.v2
  from rouge_score import rouge_scorer
  from rouge_score import scoring
label_desc: Use image node_id 5 for calling a global function with example usage: span_squad(targets, predictions) and returns: squad, re, str, str, str