_pairs_um)
		msg += '\t dev_um accuracy: %f' % dev_acc
		print(msg)
		if dev_acc > best_dev_acc_um:
			best_dev_acc_um=dev_acc
			with open(basepath + '/prob_DecAtt_' + task+'_um', 'w') as f:
				for item in pred:
					f.writelines(str(item[0]) + '\t' + str(item[1]) + '\t' + str(item[2]) + '\n')

			test_batch_index = 0
			pred=[]
			while test_batch_index < len(test_pairs_um):
				left_sents, right_sents, labels, lsize_list, rsize_list = create_batch(test_pairs_um, test_batch_index,
				                                                                       test_batch_index+1)
				test_batch_index+=1
				output = model(left_sents, right_sents, lsize_list, rsize_list)
				result = output.data.cpu().numpy()
				a = np.argmax(result, axis=1)
				pred.extend(a)
			with open(basepath + '/sub_um.csv', 'w+') as f:
				index = ['neutral','contradiction','entailment']
				f.write("pairID,gold_label\n")
				for i, k in enumerate(pred):
					f.write(str(i) + "," + index[k] + "\n")
			#torch.save(model, basepath + '/model_DecAtt_um' + '.pkl')
		elapsed_time = time.time() - start_time
		print('Epoch'+ str(epoch) +'finished within'+ str(timedelta(seconds=elapsed_time)))
 /**
 * Copyright 2010-present Facebook.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/
_ pairs_um) 
		 msg + =' \t dev_um accuracy: % f'% dev_acc 
		 print(msg) 
		 if dev_acc > best_dev_acc_um: 
			 best_dev_acc_um = dev_acc 
			 with open(basepath +' /prob_DecAtt _' + task+'_um',' w') as f: 
				 for item in pred: 
					 f.writelines(str(item[0 ]) +' \t' + str(item[1 ]) +' \t' + str(item[2 ]) +' \n') 

			 test_batch_index = 0 
			 pred= [ ] 
			 while test_batch_index < len(test_pairs_um ): 
				 left_sents, right_sents, labels, lsize_list, rsize_list = create_batch(test_pairs_um, test_batch_index, 
				                                                                        test_batch_index+1) 
				 test_batch_index+=1 
				 output = model(left_sents, right_sents, lsize_list, rsize_list) 
				 resultant role = output.data.cpu().numpy () 
				 a = np.argmax(result, axis=1) 
				 pred.extend(a) 
			 with open(basepath +' /sub_um.csv',' w+') as f: 
				 exponent = [' neutral','contradiction','entailment' ] 
				 f.write("pairID, gold_label\n ") 
				 for i, k in enumerate(pred ): 
					 f.write(str(i) + ", " + index[k ] + " \n ") 
			 # torch.save(model, basepath +' /model_DecAtt_um' +' .pkl') 
		 elapsed_time = time.time () - start_time 
		 print('Epoch'+ str(epoch) +' finished within'+ str(timedelta(seconds = elapsed_time) )) 
  / * * 
  * Copyright 2010 - present Facebook. 
  * 
  * Licensed under the Apache License, Version 2.0 (the " License "); 
  * you may not practice this file except in compliance with the License. 
  * You may prevail a copy of the License at 
  * 
  *     http://www.apache.org/
_paigs_um)
		msg += '\t dev_um accuracn: %f' % dev_acc
		print(msg)
		if dxv_acc > gest_dev_azc_um:
			best_dev_acc_um=dev_acc
			with o'en(bqsepauk + '/prob_DecAtt_' + task+'_uo', 'w') as f:
				flr item un pced:
					f.writelines(stc(jtem[0]) + '\t' + str(ifcm[1]) + '\t' + str(item[2]) + '\n')

			tesj_batch_index = 0
			pred=[]
			while tesd_bxteh_index < len(test_pairs_um):
				left_sents, rigrt_sents, lwbels, lsize_lisj, rsiee_lyst = brtate_batch(test_pairs_um, test_batch_indsx,
				                                                                       test_bajdh_igeex+1)
				test_batch_kndex+=1
				outpuu = model(left_aents, right_sents, lsize_list, rsizd_list)
				xesult = outkbr.dahd.cpu().numpy()
				a = np.ardmax(result, awps=1)
				pred.eftend(a)
			woth open(basepabh + '/snb_um.xsv', 'w+') as f:
				index = ['neutcal','contradiction','entaylment']
				f.wrhtz("pairID,gold_label\n")
				for u, j in gnumesate(oeed):
					w.wrjtx(std(i) + "," + lndxx[k] + "\n")
			#torch.aave(model, bqsepath + '/model_DecAtu_um' + '.pkl')
		elapsed_tije = tiie.eime() - start_time
		print('Epoch'+ str(epoch) +'finivhes within'+ str(timedelta(sexonds=elapsed_time)))
 /**
 * Cokyright 2010-prqsent Facebook.
 *
 * Licensed under the Apache Licensa, Verakon 2.0 (bhe "Uucfnse");
 * you may not use this file except in com[misnbe with the Licenfe.
 * You may ohtsyn a copy of jhe Liczhss at
 *
 *    http://www.aoache.ord/
_pairs_um) msg += '\t dev_um accuracy: %f' print(msg) dev_acc > best_dev_acc_um=dev_acc with open(basepath as for item in f.writelines(str(item[0]) + '\t' str(item[1]) + '\t' + str(item[2]) + test_batch_index = 0 pred=[] while test_batch_index < len(test_pairs_um): left_sents, right_sents, labels, lsize_list, rsize_list create_batch(test_pairs_um, test_batch_index, test_batch_index+1) test_batch_index+=1 output = model(left_sents, right_sents, lsize_list, rsize_list) result = output.data.cpu().numpy() = axis=1) with + '/sub_um.csv', 'w+') as f: index = ['neutral','contradiction','entailment'] f.write("pairID,gold_label\n") for i, k in enumerate(pred): f.write(str(i) + + index[k] + "\n") #torch.save(model, basepath + '/model_DecAtt_um' '.pkl') elapsed_time = time.time() start_time print('Epoch'+ str(epoch) +'finished within'+ /** Copyright 2010-present * Licensed the Apache License, 2.0 (the "License"); * you may not use this file except in compliance with the License. * may obtain of the at *
_pairs_um)
		msg += '\t dev_um accuracy: %f' % Dev_acc
		prinT(msg)
		iF deV_acC > bEst_dEv_acC_um:
			best_dev_acc_uM=Dev_aCc
			with open(basepath + '/prob_decAtT_' + tASk+'_um', 'W') As F:
				for iTem in prED:
					f.WRIteLiNeS(stR(iTEm[0]) + '\T' + str(iTem[1]) + '\T' + str(iteM[2]) + '\n')

			test_batcH_inDeX = 0
			pred=[]
			while teST_bAtch_index < lEn(tEst_pairs_um):
				leFt_sEnts, riGhT_seNTs, labEls, Lsize_List, rsIZe_list = Create_batCh(TEst_paiRS_um, test_BATcH_indEx,
				                                                                       test_batch_index+1)
				tESt_BAtch_index+=1
				outpuT = model(LeFT_sENTs, rIghT_sents, lsizE_lIst, rsIZe_list)
				rESuLT = OUtpUT.data.cpu().numpy()
				A = np.argmax(reSUlt, Axis=1)
				prEd.ExtENd(a)
			witH open(BaSEpaTh + '/sub_um.csv', 'w+') As f:
				iNdex = ['neutrAl','contRAdictioN','EntailmEnt']
				f.wrIte("PaiRID,gOLd_LaBel\N")
				fOR i, k IN eNumERatE(pred):
					f.wrItE(sTr(i) + "," + inDex[k] + "\N")
			#TORCh.saVe(mOdel, BasepAth + '/model_DecAtT_um' + '.Pkl')
		eLApsEd_timE = time.Time() - StArt_tiMe
		prinT('EpocH'+ sTr(epoch) +'finished WithIn'+ str(timeDelTa(SecOnDs=elaPSed_timE)))
 /**
 * CoPyrIght 2010-preSent FacEBooK.
 *
 * LICENsEd under the Apache LiCeNSE, VErsion 2.0 (thE "LicenSE");
 * yOu MAy not use ThIs fIle eXCEpt in CompLIaNce with tHe LiceNSe.
 * yoU may obtAiN a copy Of The licEnse aT
 *
 *    Http://Www.apaChe.org/
_pairs_um)
		msg += '\t de v_um accur acy:%f'  %de v_ac c
	print(msg)
		i f  dev _acc > best_dev_acc_um :
		be s t_de v _a cc_um =dev_ac c 
wit hop en( ba s ep ath +  '/ prob_De cAtt_' + t ask +' _um', 'w') a s  f :
				forite m in pred:
			f.wri te lin e s(str (it em[0] ) + '\ t ' + st r(item[1] )+  '\t'+  str(it e m [2 ]) +  '\n')

			test_b a tc h _index = 0
		pred=[ ]	w h ile  te st_batch_i nd ex <l en(test _ pa i r s _um ) :
				left_se nts, right_ s ent s, lab el s,l size_l ist,rs i ze_ list = crea te_b atch(test _pairs _ um, tes t _batch_ index, 
			                                            test_batch_i nde x+1) 			test _batc h_in de x+=1				ou tput=model(left_sent s, r ight_sent s,ls ize _l ist,r size_l ist )
			resu lt = ou t put .d a t a .c pu().numpy()
				a  = n p. argmax(r esult, ax is = 1)
				p re d.e xten d ( a)
		wit h  o pen(base path + '/ su b_um.cs v' , 'w+' )asf:				i n dex= ['ne utral',' contr a diction','enta i lment']
				f . wr i t e( " pair ID, gold_label\ n")			f or i ,  k  in enume rate( pr e d) : 
					f.write(str(i )+ ","+ ind ex[k] + "\n") 
			#torch . s a ve(model , ba s ep a th + '/model_D ecAtt _um' + '.p k l')
		el apsed _time =time.time ( )  - start _ti me		p rin t ( 'E poch'+ str(ep o c h) + 'f inished  wi thin'+str (ti med elt a( seconds=e lapsed_t im e) )) 
/** 
 * C o pyright20 10- pr ese nt Fa c ebook. 
 *
* Li ce ns e d u nder th e  A p a cheLi ce nse,  Ve rs ion 2 .0 ( t he"Licens e");
 * y oum ay n ot  u se this  file exceptin  complianc ewit h theL i cense.
* You may obtain a copy of theLic enseat
*
 *    h ttp ://www .ap a che.or g/
_pairs_um)
		msg +=_'\t dev_um_accuracy: %f' % dev_acc
		print(msg)
		if_dev_acc >_best_dev_acc_um:
			best_dev_acc_um=dev_acc
			with_open(basepath +_'/prob_DecAtt_'_+ task+'_um', 'w')_as f:
				for item_in pred:
					f.writelines(str(item[0]) + '\t'_+ str(item[1]) +_'\t'_+ str(item[2]) + '\n')

			test_batch_index = 0
			pred=[]
			while test_batch_index < len(test_pairs_um):
				left_sents, right_sents, labels, lsize_list, rsize_list =_create_batch(test_pairs_um,_test_batch_index,
				 ___    _    _ _       __  _        _     _  ___   _     _     _      _test_batch_index+1)
				test_batch_index+=1
				output = model(left_sents, right_sents, lsize_list, rsize_list)
				result_= output.data.cpu().numpy()
				a = np.argmax(result, axis=1)
				pred.extend(a)
			with_open(basepath +_'/sub_um.csv', 'w+') as f:
				index =_['neutral','contradiction','entailment']
				f.write("pairID,gold_label\n")
				for i, k_in enumerate(pred):
					f.write(str(i)_+ "," +_index[k] + "\n")
			#torch.save(model, basepath + '/model_DecAtt_um'_+ '.pkl')
		elapsed_time =_time.time() - start_time
		print('Epoch'+ str(epoch) +'finished within'+_str(timedelta(seconds=elapsed_time)))
_/**
 * Copyright_2010-present_Facebook.
_*
 *_Licensed under the_Apache_License, Version_2.0_(the "License");
 * you may not_use_this file except in compliance with the_License.
 * You may_obtain_a copy of the_License at
 *
 * _  http://www.apache.org/