code: def get_bert_qa_prediction(features, example, start_end_logits):
      prelim_predictions = []
      for i, feature in enumerate(features):
          for start_index in _get_best_indices(
              start_end_logits[i][0], 20
          ):
              for end_index in _get_best_indices(
                  start_end_logits[i][1], 20
              ):
                  if start_index >= len(
                      feature["tokens"]
                  ) or end_index >= len(feature["tokens"]):
                      continue
                  if (
                      start_index not in feature["token_to_orig_map"]
                      or end_index not in feature["token_to_orig_map"]
                  ):
                      continue
                  if not feature["token_is_max_context"].get(
                      start_index, False
                  ):
                      continue
                  if (
                      end_index < start_index
                      or end_index - start_index + 1 > 30
                  ):
                      continue
  
                  prelim_predictions.append(
                      {
                          "feature_index": i,
                          "start_index": start_index,
                          "end_index": end_index,
                          "start_logit": start_end_logits[i][
                              0, start_index
                          ],
                          "end_logit": start_end_logits[i][
                              1, end_index
                          ],
                      }
                  )
      predictions = sorted(
          prelim_predictions,
          key=lambda x: (x["start_logit"] + x["end_logit"]),
          reverse=True,
      )
  
      if len(predictions) > 0:
          feature = features[predictions[0]["feature_index"]]
          tok_tokens = feature["tokens"][
              predictions[0]["start_index"] : (
                  predictions[0]["end_index"] + 1
              )
          ]
          orig_doc_start = feature["token_to_orig_map"][
              predictions[0]["start_index"]
          ]
          orig_doc_end = feature["token_to_orig_map"][
              predictions[0]["end_index"]
          ]
          orig_tokens = example["context"][
              orig_doc_start : (orig_doc_end + 1)
          ]
          tok_text = (
              " ".join(tok_tokens).replace(" ##", "").replace("##", "")
          )
          tok_text = " ".join(tok_text.strip().split())
          orig_text = " ".join(orig_tokens)
          return _get_final_text(tok_text, orig_text)
      return "empty"
  
file_path: tinygrad/examples/mlperf/helpers.py
imports: from collections import OrderedDict
  import unicodedata
  import numpy
  from scipy import signal
label_desc: Use image node_id 12 for calling a global function with example usage: get_bert_qa_prediction(features, example, start_end_logits) and returns: str, _get_final_text