write a generate_training_dataset.py, and correspond shell script to foll parameters. --orig-inj-datapath (use /data/local/hujk/IPIBench/topicattack/data/ crafted_instruction_data_tri_injection_qa.json in sh), for each data, it extract inst=data["instruction"] , cont=data["input"], ans=data["output"], inj=data["injection"], and generate a new dataset and save to --output-path (use crafted_instruction_data_tri_injection_qa.jsonl in sh), and it create a list of message in this format. user() means {"role":"user", "content": content}, tool/assistent so on. create rng with seed 42, and use it in following code

create rng with seed 42, and use it in following code

dataset_message_candidate = []
for each data in datasets:
    message_list = [[]]*7
    inst, cont, ans = select from other data randomly from 2nd run, inst/cont are paired, a.k.a in same data
    inst , inj= f"<data>{inst}</data>", f"<data>{inj}</data>" #warp <data></data> to inst and inj
    message_list[0] += user(inst) + tool(cont) + assistant(ans)
    message_list[1] += user(inst + cont) + assistant(ans)
    message_list[2] += user(inst + cont + inj) + assistant(ans)
    message_list[3] += user(inst) + tool(cont + inj) + assistant(ans)
    inst2, cont2 = select from other data randomly, inst2/cont2 are paired, a.k.a in same data
    inst , inj= f"<data>{inst2}</data>", f"<data>{cont2}</data>"
    message_list[4] += user(inst) + tool(suffile([cont, inst2])) + assistant(ans)
    message_list[5] += user(inst) + tool(suffile([cont, cont2])) + assistant(ans)
    message_list[6] += user(inst) + tool(suffile([cont, inst2, const2])) + assistant(ans)
    dataset_message_candidate += message_list

output_dataset = []
for _ in range(len(datasets)):
    temp_message_list = []
    for i in range(random(1,10)):
        temp_message_list += random choose(dataset_message_candidate)
        remove last assistant(ans)
    output_dataset += temp_message_list