code: def _PartitionChunks(chunks):
    
    partitions = [[]]
    partition_size = 0
  
    for chunk in chunks:
      cursize = len(chunk["blob_chunk"])
      if (cursize + partition_size > BLOB_CHUNK_SIZE or
          len(partitions[-1]) >= CHUNKS_PER_INSERT):
        partitions.append([])
        partition_size = 0
      partitions[-1].append(chunk)
      partition_size += cursize
  
    return partitions
docs: Groups chunks into partitions of size safe for a single INSERT.