code: def main():
      args = parse_args()
  
      # TODO: make ssplit an argument
      ssplit_pipe = selftrain.build_ssplit_pipe(
          ssplit=True, lang=args.lang
      )
      tag_pipe = selftrain.build_tag_pipe(ssplit=False, lang=args.lang)
      parser_pipes = selftrain.build_parser_pipes(
          args.lang, args.models
      )
  
      # create a blank file.  we will append to this file so that partial results can be used
      with open(args.output_file, "w") as fout:
          pass
  
      docs = read_file(args.input_file)
      logger.info("Read %d lines from %s", len(docs), args.input_file)
      docs = selftrain.split_docs(docs, ssplit_pipe)
  
      # breaking into chunks lets us output partial results and see the
      # progress in log files
      accepted_trees = set()
      if len(docs) > 10000:
          chunks = tqdm(np.array_split(docs, 100), disable=False)
      else:
          chunks = [docs]
      for chunk in chunks:
          new_trees = selftrain.find_matching_trees(
              chunk,
              args.num_sentences,
              accepted_trees,
              tag_pipe,
              parser_pipes,
              shuffle=False,
              chunk_size=100,
          )
          accepted_trees.update(new_trees)
  
          with open(args.output_file, "a") as fout:
              for tree in sorted(new_trees):
                  fout.write(tree)
                  fout.write("\n")
  
file_path: stanza/stanza/utils/datasets/constituency/selftrain_single_file.py
imports: import argparse
  import io
  import logging
  import os
  import numpy
  import stanza
  from stanza.utils.datasets.constituency import selftrain
  from stanza.utils.get_tqdm import get_tqdm
label_desc: Use image node_id 3 for calling a global function with example usage: main() without return types