# Evaluate with Proxies

v = 0
mp_score = [0 for _ in AVAILABLE_PROXIES]
if(self.MULTI_PROXY):
    ds = None
    x_proxy, y_proxy = None, None
    igen = int(self.i_model/self.pop_size)
    if(self.train_with_gen):
        if(self.pss):
            ds = self.train_gen[igen%self.pss].__getitem__(0)
        else:
            ds = self.train_gen.__getitem__(igen)
        x_proxy = ds[0]
        y_proxy = ds[1]
    else:
        x_proxy = self.x_train_full[igen*self.batch_size:(igen+1)*self.batch_size]
        y_proxy = self.y_train_full[igen*self.batch_size:(igen+1)*self.batch_size]
    bs = len(x_proxy)
    try:
        for i_proxy,proxy in enumerate(AVAILABLE_PROXIES):
            if(AVAILABLE_PROXIES[proxy].__code__.co_argcount==2):
                mp_score[i_proxy] = AVAILABLE_PROXIES[proxy](model,self.input_shape)
            else:
                if(proxy)=='NASWOT':
                    mp_score[i_proxy] = AVAILABLE_PROXIES[proxy](naswot_model,x_proxy,y_proxy,bs)
                else:
                    mp_score[i_proxy] = AVAILABLE_PROXIES[proxy](model,x_proxy,y_proxy,bs)
    except:
        import traceback
        traceback.print_exc()
        print('Could not calculate multi proxy scores!')
    v = sum(mp_score)
elif(self.SYNFLOW):
    try:
        v = get_synflow_score(model,self.input_shape)
    except:
        import traceback
        traceback.print_exc()
        print('Could not calculate Synflow score!')
        v = 0
elif(self.NASWOT):
    ds = None
    x_naswot, y_naswot = None, None
    igen = int(self.i_model/self.pop_size)
    if(self.train_with_gen):
        if(self.pss):
            ds = self.train_gen[igen%self.pss].__getitem__(0)
        else:
            ds = self.train_gen.__getitem__(igen)
        x_naswot = ds[0]
        y_naswot = ds[1]
    else:
        x_naswot = self.x_train_full[igen*self.batch_size:(igen+1)*self.batch_size]
        y_naswot = self.y_train_full[igen*self.batch_size:(igen+1)*self.batch_size]
    bs = len(x_naswot)
    get_naswot_score(naswot_model,x_naswot,y_naswot,bs)
    # del model
    # model.save("model-{}.h5".format(self.i_model))
    gc.collect()
