code: def random_shuffle_by_prefixes(
      input_dir, output_dir, short_name, prefix_map
  ):
      input_files = os.listdir(input_dir)
      input_files = sorted(input_files)
  
      file_divisions = defaultdict(list)
      for filename in input_files:
          for division in prefix_map.keys():
              for prefix in prefix_map[division]:
                  if filename.startswith(prefix):
                      break
              else:  # for/else is intentional
                  continue
              break
          else:  # yes, stop asking
              raise ValueError(
                  "Could not assign %s to any of the divisions in the prefix_map"
                  % filename
              )
          # print("Assigning %s to %s because of %s" % (filename, division, prefix))
          file_divisions[division].append(filename)
  
      num_train_files = 0
      num_dev_files = 0
      num_test_files = 0
      for division in file_divisions.keys():
          print()
          print(
              "Processing %d files from %s"
              % (len(file_divisions[division]), division)
          )
          d_train, d_dev, d_test = random_shuffle_files(
              input_dir,
              file_divisions[division],
              output_dir,
              "%s-%s" % (short_name, division),
          )
          num_train_files += d_train
          num_dev_files += d_dev
          num_test_files += d_test
  
      print()
      print(
          "After shuffling: Train files: %d  Dev files: %d  Test files: %d"
          % (num_train_files, num_dev_files, num_test_files)
      )
      dataset_divisions = [
          "%s-%s" % (short_name, division)
          for division in file_divisions
      ]
      combine_dataset(
          output_dir, output_dir, dataset_divisions, short_name
      )
  
imports: from collections import defaultdict
  import json
  import os
  import random
  from stanza.models.common.doc import Document
  import stanza.utils.datasets.ner.prepare_ner_file
label_desc: Use image node_id 10 for calling a global function with example usage: random_shuffle_by_prefixes(input_dir, output_dir, short_name, prefix_map) without return types