code: def segment_sentences(input):
      articles, output_names, rank, segmenter = input
      print(
          "process {} needs to segment {} articles".format(
              rank, len(articles)
          )
      )
      sentences = {}
      for i, article in enumerate(articles):
          sentences[article] = segmenter.segment_string(
              articles[article]
          )
  
          if i % 100 == 0:
              print("process {} finish article {}".format(rank, i))
  
      print("process {} finish segment".format(rank))
      # return_dict.update(sentences)
      total_length = 0
      for article_id in sentences:
          total_length += len(sentences[article_id])
  
      # try to average size of output size
      ideal_length = total_length // len(output_names) + 1
      output_list = defaultdict(lambda: [])
      output_index = 0
      current_length = 0
  
      for article_id in sentences:
          current_length += len(sentences[article_id])
          output_list[output_names[output_index]].append(article_id)
          if current_length >= ideal_length:
              output_index += 1
              current_length = 0
  
      print("process {} start to write to disk".format(rank))
      for output_name in output_names:
          with open(output_name, mode="w", newline="\n") as f:
              for article_id in output_list[output_name]:
                  for line in sentences[article_id]:
                      f.write(line + "\n")
  
                  f.write("\n")
  
      print("process {} finish to write to disk".format(rank))
  
file_path: gluon-nlp/scripts/processing/segment_sentences.py
imports: import statistics
  import nltk
  import multiprocessing
  from collections import defaultdict
  from itertools import islice
  import time
  import os
label_desc: Use image node_id 1 for calling a global function with example usage: segment_sentences(input) without return types