code: def gen_negative_instances(item_set, infile, outfile, neg_num):
      item_list = list(item_set)
      item_num = len(item_set)
      print(
          "negative sampling for file {0}...".format(
              os.path.basename(infile)
          )
      )
      with open(infile, "r") as rd:
          lines = rd.readlines()
      total_cnt, cur_cnt = len(lines), 0
      _t0 = time.time()
      with open(outfile, "w") as wt:
          for line in lines:
              cur_cnt += 1
              if cur_cnt % 100 == 0:
                  print(
                      "\rprocess line num {0} / {1}...time elapses: {2:.1f}s".format(
                          cur_cnt, total_cnt, time.time() - _t0
                      ),
                      end="",
                  )
              words = line.strip().split(",")
  
              wt.write("{0}\n".format(words[0]))
              wt.write("{0}\n".format(words[1]))
  
              for _ in range(neg_num):
                  item = item_list[random.randint(0, item_num - 1)]
                  wt.write("{0}\n".format(item))
      print("\tdone.")
  
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 19 for calling a global function with example usage: gen_negative_instances(item_set, infile, outfile, neg_num) without return types