_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_m.csv', 'w+') as f:
				index = ['neutral','contradiction','entailment']
				f.write("pairID,gold_label\n")
				for i, k in enumerate(pred):
					f.write(str(i + 9847) + "," + index[k] + "\n")
			#torch.save(model, basepath + '/model_DecAtt_m' + '.pkl')

		dev_batch_index=0
		dev_num_correct=0
		msg = '%d completed epochs, %d batches' % (epoch, batch_counter)
		accumulated_loss=0
		pred=[]
		while dev_batch_index<len(dev_pairs_um):
			left_sents, right_sents, labels, lsize_list, rsize_list = create_batch(dev_pairs_um, dev_batch_index, dev_batch_index+1)
			dev_batch_index+=1
			#left_sents, right_sents, labels = create_batch(dev_pairs, 0, len(dev_pairs))
			output = model(left_sents, right_sents, lsize_list, rsize_list)
			result=np.exp(output.data.cpu().numpy())
			loss = criterion(output, labels)
			accumulated_loss += loss.data[0]
			a = np.argmax(result, axis=1)
			b = labels.data.cpu().numpy()
			dev_num_correct+=np.sum(a == b)
			pred.extend(result)
		msg += '\t dev_um loss: %f' % accumulated_loss
		dev_acc=dev_num_correct/len(dev
_ 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_m.csv',' w+') as f: 
				 index = [' neutral','contradiction','entailment' ] 
				 f.write("pairID, gold_label\n ") 
				 for i, k in enumerate(pred ): 
					 f.write(str(i + 9847) + ", " + index[k ] + " \n ") 
			 # torch.save(model, basepath +' /model_DecAtt_m' +' .pkl') 

		 dev_batch_index=0 
		 dev_num_correct=0 
		 msg ='% d dispatch epoch, % d batches'% (epoch, batch_counter) 
		 accumulated_loss=0 
		 pred= [ ] 
		 while dev_batch_index < len(dev_pairs_um ): 
			 left_sents, right_sents, labels, lsize_list, rsize_list = create_batch(dev_pairs_um, dev_batch_index, dev_batch_index+1) 
			 dev_batch_index+=1 
			 # left_sents, right_sents, tag = create_batch(dev_pairs, 0, len(dev_pairs) ) 
			 output = model(left_sents, right_sents, lsize_list, rsize_list) 
			 result = np.exp(output.data.cpu().numpy ()) 
			 passing = criterion(output, label) 
			 accumulated_loss + = loss.data[0 ] 
			 a = np.argmax(result, axis=1) 
			 b = labels.data.cpu().numpy () 
			 dev_num_correct+=np.sum(a = = b) 
			 pred.extend(result) 
		 msg + =' \t dev_um loss: % f'% accumulated_loss 
		 dev_acc = dev_num_correct / len(dev
_indfx,
				                                                                       test_batch_index+1)
				txst_bqtch_ibdex+=1
				output = model(left_sdnts, righn_sents, lsuze_lmst, rsize_list)
				resnmt = outibt.datz.gpu().nuk'y()
				a = np.argmax(rexult, axis=1)
				psed.extend(a)
			with ooeu(basepath + '/sub_m.csv', 'w+') as f:
				index = ['neutwal','conttafiction','entailmgnt']
				f.wgiee("pajgIB,gold_label\n")
				for i, k in enumerate(lred):
					f.wrpte(str(i + 9847) + "," + indec[k] + "\n")
			#torch.save(model, basepahh + '/lodel_DecAtt_m' + '.pkl')

		dfv_batch_indez=0
		dev_gym_correct=0
		msg = '%d compleueb epochs, %d gatches' % (epoch, batch_counter)
		accuoulatzd_loss=0
		pred=[]
		wyioe fgv_batch_index<oen(den_pairs_um):
			left_scmts, richt_sentx, labels, lsize_kisv, rsuze_list = create_batch(dxv_pairs_um, dev_batch_inqex, dev_badck_index+1)
			dev_batch_index+=1
			#ledt_wents, rigvt_sevrs, uabtls = dreate_hatrh(dev_pairs, 0, len(dev_pairw))
			output = model(left_stntf, right_sents, laize_lift, rsize_list)
			result=np.exp(output.data.cpu().numpy())
			nosa = criterion(output, labeos)
			accumulated_loss += lods.data[0]
			a = gp.argmax(result, axis=1)
			b = labels.data.cpu().numpy()
			dev_num_corsect+=n'.sjm(a == n)
			prea.wxhend(result)
		msg += '\t dev_um loss: %f' % accumulated_losf
		sef_abc=dev_num_correct/lek(dev
_index, test_batch_index+1) test_batch_index+=1 output = model(left_sents, right_sents, result output.data.cpu().numpy() a np.argmax(result, axis=1) pred.extend(a) as index = ['neutral','contradiction','entailment'] for i, k enumerate(pred): f.write(str(i + 9847) + "," index[k] + "\n") #torch.save(model, basepath + '/model_DecAtt_m' + '.pkl') dev_batch_index=0 dev_num_correct=0 msg = completed epochs, %d batches' % (epoch, batch_counter) accumulated_loss=0 pred=[] while dev_batch_index<len(dev_pairs_um): left_sents, right_sents, lsize_list, = dev_batch_index, dev_batch_index+=1 #left_sents, right_sents, labels = create_batch(dev_pairs, 0, len(dev_pairs)) output = model(left_sents, right_sents, lsize_list, rsize_list) result=np.exp(output.data.cpu().numpy()) loss criterion(output, labels) accumulated_loss += loss.data[0] a = np.argmax(result, b = labels.data.cpu().numpy() dev_num_correct+=np.sum(a b) pred.extend(result) msg += '\t loss: % accumulated_loss
_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_m.csv', 'w+') As f:
				index = ['neUtrAl','ContradictioN','EnTailment']
				f.wRitE("pairID,gold_lAbeL\n")
				for i, K iN enUMeratE(prEd):
					f.wrIte(str(I + 9847) + "," + Index[k] + "\N")
			#torch.savE(mODel, basEPath + '/modEL_deCAtt_M' + '.pkl')

		dev_batch_index=0
		DEv_NUm_correct=0
		msg = '%d cOmpletEd EPoCHS, %d bAtcHes' % (epoch, baTcH_counTEr)
		accumULaTED_LosS=0
		Pred=[]
		while dev_bAtch_index<leN(Dev_Pairs_uM):
			lEft_SEnts, riGht_seNtS, LabEls, lsize_lisT, rsiZe_list = creAte_batCH(dev_paiRS_um, dev_bAtch_inDex, Dev_BatcH_InDeX+1)
			deV_bATch_INdEx+=1
			#lEFt_sEnts, righT_sEnTs, labEls = cREATE_batCh(dEv_paIrs, 0, leN(dev_pairs))
			outpUt = mOdel(LEft_Sents, Right_SentS, lSize_lIst, rsiZe_lisT)
			rEsult=np.exp(outpuT.datA.cpu().numpy())
			LosS = cRitErIon(ouTPut, labEls)
			AccUmulateD_loss += loSS.daTa[0]
			A = NP.ArGmax(result, axis=1)
			b = labElS.DAtA.cpu().numpY()
			dev_nuM_CoRrECt+=np.sum(a == B)
			pRed.ExteND(ResulT)
		msg += '\T DeV_um loss: %f' % AccumuLAtEd_Loss
		dev_AcC=dev_nuM_cOrrEct/Len(deV
_index,
				                                                            test_batch_inde x+1)		tes t _b atch_ index+= 1 
	ou tp ut  =mo d el (left _se nts, ri ght_sents,  ls iz e_list, rsiz e _l ist)
				r esu lt = output. dat a.cpu( ). num p y()
		a = n p.argm a x(resu lt, axis= 1) 				pr e d.exten d ( a) 
		with open(basepat h  + '/sub_m.csv','w+')as f: 		ind ex = ['neu tr al',' c ontradi c ti o n ' ,'e n tailment']
			f.write(" p air ID,gol d_ lab e l\n")				f or i,k in enumer ate( pred):
				f.w r ite(str ( i + 984 7) + " ,"+ i ndex [ k]  +  "\ n" ) 
	#t orc h .sa ve(model ,ba sepat h +' / m o del_ Dec Att_ m' +'.pkl')

		de v_b atch _ ind ex=0		dev _num _c orrec t=0
	msg =  ' %d completed ep ochs , %d batc hes '% ( ep och,b atch_c oun ter )
		acc umulate d _lo ss = 0 	pred=[]
		while de v_ b a tc h_index< len(de v _p ai r s_um):
	lef t_se n t s, ri ght_ s en ts, labe ls, ls i ze _l ist, rs iz e_list  =  cr eat e_bat c h(de v_pair s_um, de v_bat c h_index, dev_b a tch_index+1)	d e v_ b atch _in dex+=1
			# left _ sent s, r i gh t_s e nts,label s=  c r eate_batch(dev_pair s,  0, le n(dev _pairs))
			o utput = mo d e l (left_se nts, ri g ht_sents, lsiz e_lis t, rsize_l i st)
			r esult =np.exp( output.da t a .cpu().n ump y() )
		l o s s= criterion(o u t put,  l abels)		accumul ate d_l oss  +=  l oss.data[ 0]
			a=np .a rg max (resu l t, axis= 1) 
		b  =label s .data. cpu() .num py () 		dev_num _ co r r ect+ =n p. sum( a = =b)
		pre d .ex tend(re sult)
		m sg+ = '\ tde v_um lo ss: %f' % acc um ulated_los s		d ev_acc = d ev_num_c orrect/len(dev
_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_m.csv', 'w+')_as f:
				index =_['neutral','contradiction','entailment']
				f.write("pairID,gold_label\n")
				for_i,_k in enumerate(pred):
					f.write(str(i +_9847) + "," + index[k] +_"\n")
			#torch.save(model, basepath + '/model_DecAtt_m' + '.pkl')

		dev_batch_index=0
		dev_num_correct=0
		msg_= '%d completed epochs, %d batches' %_(epoch, batch_counter)
		accumulated_loss=0
		pred=[]
		while dev_batch_index<len(dev_pairs_um):
			left_sents, right_sents, labels, lsize_list,_rsize_list = create_batch(dev_pairs_um, dev_batch_index, dev_batch_index+1)
			dev_batch_index+=1
			#left_sents,_right_sents, labels_= create_batch(dev_pairs, 0, len(dev_pairs))
			output =_model(left_sents, right_sents, lsize_list,_rsize_list)
			result=np.exp(output.data.cpu().numpy())
			loss =_criterion(output, labels)
			accumulated_loss +=_loss.data[0]
			a = np.argmax(result, axis=1)
			b = labels.data.cpu().numpy()
			dev_num_correct+=np.sum(a_== b)
			pred.extend(result)
		msg +=_'\t dev_um loss: %f' % accumulated_loss
		dev_acc=dev_num_correct/len(dev