code: def get_batches(qp_pairs, batch_size, need_sort=True):
      """
      Get batches data and shuffle.
      """
      if need_sort:
          qp_pairs = sorted(
              qp_pairs,
              key=lambda qp: (len(qp["passage_tokens"]), qp["id"]),
              reverse=True,
          )
      batches = [
          {"qp_pairs": qp_pairs[i : (i + batch_size)]}
          for i in range(0, len(qp_pairs), batch_size)
      ]
      shuffle(batches)
      return batches
  
file_path: nni/examples/trials/weight_sharing/ga_squad/data.py
imports: import csv
  import json
  from random import shuffle
  import numpy
label_desc: Use image node_id 5 for calling a global function with example usage: get_batches(qp_pairs, batch_size, need_sort) and returns: batches