code: def write_list(out_filename, dataset):
      """
      Write a list of items to the given output file
  
      Expected: list(SentimentDatum)
      """
      formatted_dataset = [line._asdict() for line in dataset]
      # Rather than write the dataset at once, we write one line at a time
      # Using `indent` puts each word on a separate line, which is rather noisy,
      # but not formatting at all makes one long line out of an entire dataset,
      # which is impossible to read
      # json.dump(formatted_dataset, fout, indent=2, ensure_ascii=False)
  
      with open(out_filename, "w") as fout:
          fout.write("[\n")
          for idx, line in enumerate(formatted_dataset):
              fout.write("  ")
              json.dump(line, fout, ensure_ascii=False)
              if idx < len(formatted_dataset) - 1:
                  fout.write(",")
              fout.write("\n")
          fout.write("]\n")
  
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 1 for calling a global function with example usage: write_list(out_filename, dataset) without return types