// The next lines sort all cross-request batch elements by the token length of right_.
// Note that cross-request batch element can in turn be a client batch.
mega_batch_key_list = [
(max_tokens(self.right_tensorizer.tokenize(x[0], x[2])), n)
for (n, x) in enumerate(mega_batch)
]
sorted_mega_batch_key_list = sorted(mega_batch_key_list)
sorted_mega_batch = [mega_batch[n]for (key, n) in sorted_mega_batch_key_list]
// TBD: allow model server to specify batch size in goals dictionary
max_bs: int = 10