code: def split_train_valid_file(infile_list, outdir, ratio=0.8):
      gt_pairs = set()
      for infile in infile_list:
          with open(infile, "r") as rd:
              for line in rd:
                  words = line.strip().split(",")
                  pair = (
                      (words[0], words[1])
                      if words[0] < words[1]
                      else (words[1], words[0])
                  )
                  gt_pairs.add(pair)
  
      gt_pairs = list(gt_pairs)
      random.shuffle(gt_pairs)
      with open(
          os.path.join(outdir, "item2item_train.txt"), "w"
      ) as wt_train, open(
          os.path.join(outdir, "item2item_valid.txt"), "w"
      ) as wt_valid:
          for p in gt_pairs:
              if random.random() < ratio:
                  wt_train.write("{0},{1}\n".format(p[0], p[1]))
              else:
                  wt_valid.write("{0},{1}\n".format(p[0], p[1]))
  
imports: import codecs
  import pickle
  import time
  import os
  from datetime import datetime
  import random
  import numpy
  import math
  from multiprocessing import Process
  from utils.general import *
  from utils.data_helper import *
label_desc: Use image node_id 20 for calling a global function with example usage: split_train_valid_file(infile_list, outdir, ratio) without return types