code: def batch_by_token_count(idx_target_lengths, token_limit):
      batches = []
      current_batch = []
      current_token_count = 0
      for idx, target_length in idx_target_lengths:
          if current_token_count + target_length > token_limit:
              batches.append(current_batch)
              current_batch = [idx]
              current_token_count = target_length
          else:
              current_batch.append(idx)
              current_token_count += target_length
  
      if current_batch:
          batches.append(current_batch)
  
      return batches
  
imports: import json
  import math
  from collections import namedtuple
  from typing import List, Tuple
  import sentencepiece
  import torch
  import torchaudio
  from torchaudio.models import Hypothesis
label_desc: Use image node_id 2 for calling a global function with example usage: batch_by_token_count(idx_target_lengths, token_limit) and returns: batches