code: def sample_negative_and_write_to_file(
      outfilename,
      samples,
      neg_cnt,
      positive_pairs,
      item_list,
      sample_probs,
      remove_false_negative=False,
      process_id=0,
      process_num=4,
  ):
      with open(outfilename, "w") as wt:
          _cnt, _total = 0, len(samples)
          _t0 = time.time()
          for sample in samples:
              _cnt += 1
              if _cnt % 1000 == 0:
                  print(
                      "\rsampling process {3}:  {0} / {1}, time elapses: {2:.1f}s".format(
                          _cnt, _total, time.time() - _t0, process_id
                      ),
                      end=" ",
                  )
              if _cnt % process_num != process_id:
                  continue
              words = sample.split("%")
              label, user_tag, item_id = words[0].split(" ")
              wt.write(sample + "\n")
              sampled_items_indices = reparameter_sampling(
                  neg_cnt, sample_probs
              )
              for sampled_item_idx in sampled_items_indices:
                  sampled_item = item_list[sampled_item_idx]
                  if (
                      not remove_false_negative
                      or (words[1], sampled_item) not in positive_pairs
                  ):
                      wt.write(
                          "{0} {1} {2}%{3}\n".format(
                              0, user_tag, sampled_item, words[1]
                          )
                      )
      print("\tsampling process {0} done.".format(process_id))
  
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 9 for calling a global function with example usage: sample_negative_and_write_to_file(outfilename, samples, neg_cnt, positive_pairs, item_list, sample_probs, remove_false_negative, process_id, process_num) without return types