code: def convert_example_to_features(example, tokenizer):
      query_tokens = tokenizer.tokenize(example["question"])
  
      if len(query_tokens) > 64:
          query_tokens = query_tokens[:64]
  
      tok_to_orig_index = []
      orig_to_tok_index = []
      all_doc_tokens = []
      for i, token in enumerate(example["context"]):
          orig_to_tok_index.append(len(all_doc_tokens))
          sub_tokens = tokenizer.tokenize(token)
          for sub_token in sub_tokens:
              tok_to_orig_index.append(i)
              all_doc_tokens.append(sub_token)
  
      max_tokens_for_doc = 384 - len(query_tokens) - 3
  
      doc_spans = []
      start_offset = 0
      while start_offset < len(all_doc_tokens):
          length = len(all_doc_tokens) - start_offset
          length = min(length, max_tokens_for_doc)
          doc_spans.append((start_offset, length))
          if start_offset + length == len(all_doc_tokens):
              break
          start_offset += min(length, 128)
  
      outputs = []
      for di, (doc_start, doc_length) in enumerate(doc_spans):
          tokens = []
          token_to_orig_map = {}
          token_is_max_context = {}
          segment_ids = []
          tokens.append("[CLS]")
          segment_ids.append(0)
          for token in query_tokens:
              tokens.append(token)
              segment_ids.append(0)
          tokens.append("[SEP]")
          segment_ids.append(0)
  
          for i in range(doc_length):
              split_token_index = doc_start + i
              token_to_orig_map[len(tokens)] = tok_to_orig_index[
                  split_token_index
              ]
              token_is_max_context[len(tokens)] = _check_is_max_context(
                  doc_spans, di, split_token_index
              )
              tokens.append(all_doc_tokens[split_token_index])
              segment_ids.append(1)
          tokens.append("[SEP]")
          segment_ids.append(1)
  
          input_ids = tokenizer.convert_tokens_to_ids(tokens)
          input_mask = [1] * len(input_ids)
  
          while len(input_ids) < 384:
              input_ids.append(0)
              input_mask.append(0)
              segment_ids.append(0)
  
          assert len(input_ids) == 384
          assert len(input_mask) == 384
          assert len(segment_ids) == 384
  
          outputs.append(
              {
                  "input_ids": np.expand_dims(
                      np.array(input_ids), 0
                  ).astype(np.float32),
                  "input_mask": np.expand_dims(
                      np.array(input_mask), 0
                  ).astype(np.float32),
                  "segment_ids": np.expand_dims(
                      np.array(segment_ids), 0
                  ).astype(np.float32),
                  "token_to_orig_map": token_to_orig_map,
                  "token_is_max_context": token_is_max_context,
                  "tokens": tokens,
              }
          )
  
      return outputs
  
file_path: tinygrad/extra/datasets/squad.py
imports: import json
  import os
  from pathlib import Path
  from transformers import BertTokenizer
  import numpy
  from tinygrad.helpers import fetch
label_desc: Use image node_id 3 for calling a global function with example usage: convert_example_to_features(example, tokenizer) and returns: outputs