text: import os
  import pickle
  import multiprocessing
  from multi_pre_inf_ol import func_i_a, func_u_a, P_a, Q_a
  
  if __name__ == '__main__':
      cores = multiprocessing.cpu_count()
      cores = int(cores / 2)
      pool = multiprocessing.Pool(processes=cores)
  
      influence_user_dict = dict()
      xs = range(P_a.shape[0])
      ct = 0
      print('Start Calculating Amazon User Influence!')
      for y in pool.imap(func_u_a, xs):
          influence_user_dict[ct] = y
          ct += 1
          if ct % 1000 == 0:
              print('already finish %d users' % ct)
          if ct == P_a.shape[0]:
              if not os.path.exists('./online_result/amazon/'):
                  os.makedirs('./online_result/amazon/')
              with open('./online_result/amazon/influence_user_dict_ol.pkl', 'wb') as f:
                  pickle.dump(influence_user_dict, f)
              break
      print('Finish Calculate Amazon User Influence!')
      influence_item_dict = dict()
      xs = range(Q_a.shape[0])
      ct = 0
      print('Start Calculating Amazon Item Influence!')
      for y in pool.imap(func_i_a, xs):
          influence_item_dict[ct] = y
          ct += 1
          if ct % 1000 == 0:
              print('Already Finish %d items' % ct)
          if ct == Q_a.shape[0]:
              with open('./online_result/amazon/influence_item_dict_ol.pkl', 'wb') as f:
                  pickle.dump(influence_item_dict, f)
              break
      print('Finish Calculate Amazon Item Influence!')
  