code: def create_fb_format(inpath, outpath, use_history):
      print("[building fbformat]")
      start_time = time.time()
  
      ftrain = open(os.path.join(outpath, "train.txt"), "w")
      fvalid = open(os.path.join(outpath, "valid.txt"), "w")
      ftest = open(os.path.join(outpath, "test.txt"), "w")
  
      movie_dirs = get_list_of_files(inpath)
      total_movie_dirs = len(movie_dirs)
      total_files = sum([len(l) for l in movie_dirs.values()])
      print(
          "[Found %d movie folders and %d subtitles within %s in %d seconds]"
          % (
              total_movie_dirs,
              total_files,
              inpath,
              time.time() - start_time,
          )
      )
  
      assert (
          total_movie_dirs == NUM_MOVIE_FOLDERS
      ), "Incorrect number of movies"
      assert (
          total_files == NUM_SUBTITLES_FILES
      ), "Incorrect number of files"
  
      processor = DataProcessor(use_history)
  
      with multiprocessing.Pool(processes=os.cpu_count()) as pool:
          for i, s in enumerate(
              pool.imap(processor, tqdm.tqdm(movie_dirs.items()))
          ):
              handle = ftrain
              # TODO: Shall we use smaller valid/test sets? Even 10% is A LOT here
              if i % 10 == 0:
                  handle = ftest
              if i % 10 == 1:
                  handle = fvalid
              handle.write(s)
  
      ftrain.close()
      fvalid.close()
      ftest.close()
  
      print(
          "[Data has been successfully extracted in %d seconds]"
          % (time.time() - start_time,)
      )
  
imports: import parlai.core.build_data
  import glob
  import gzip
  import multiprocessing
  import os
  import re
  import sys
  import time
  import tqdm
  import xml.etree.ElementTree
  from parlai.core.build_data import DownloadableFile
  from parlai.utils.io import PathManager
label_desc: Use image node_id 11 for calling a global function with example usage: create_fb_format(inpath, outpath, use_history) without return types