code: def write_dataset(filename, trees, split):
      """
      Write all of the trees to the given filename
      """
      count = 0
      with open(filename, "w") as fout:
          # TODO: make some fraction have random spaces inserted
          for tree in trees:
              count = count + 1
              words = tree.leaf_labels()
              write_sentence(fout, words, spaces=0.0)
              # We include a small number of spaces to teach the model
              # that spaces always separate a word
              if split == "train" and random.random() < 0.1:
                  count = count + 1
                  write_sentence(fout, words, spaces=0.05)
      print(
          "Wrote %d sentences from %d trees to %s"
          % (count, len(trees), filename)
      )
  
file_path: stanza/stanza/utils/datasets/tokenization/convert_my_alt.py
imports: import os
  import random
  from stanza.models.constituency.tree_reader import read_trees
label_desc: Use image node_id 5 for calling a global function with example usage: write_dataset(filename, trees, split) without return types