code: def write_splits(out_directory, snippets, splits):
      """
      Write the given list of items to the split files in the specified output directory
      """
      total_weight = sum(split.weight for split in splits)
      divs = []
      subtotal = 0.0
      for split in splits:
          divs.append(int(len(snippets) * subtotal / total_weight))
          subtotal = subtotal + split.weight
      # the last div will be guaranteed to be the full thing - no math used
      divs.append(len(snippets))
  
      for i, split in enumerate(splits):
          filename = os.path.join(out_directory, split.filename)
          print(
              "Writing {}:{} to {}".format(
                  divs[i], divs[i + 1], filename
              )
          )
          write_list(filename, snippets[divs[i] : divs[i + 1]])
  
file_path: stanza/stanza/utils/datasets/sentiment/process_utils.py
imports: import csv
  import glob
  import json
  import os
  import tempfile
  from collections import namedtuple
  from tqdm import tqdm
  import stanza
  from stanza.models.classifiers.data import SentimentDatum
label_desc: Use image node_id 3 for calling a global function with example usage: write_splits(out_directory, snippets, splits) without return types