def predict_loop(self, model, eval_dataloader, output_file="result.pkl"):
        """refactored from line 144:
        https://github.com/DmZhukov/CrossTask/blob/master/train.py
        """
        ctx = 0
        model.eval()
        model = model.to(ctx)

        with torch.no_grad():
            outputs = eval_dataloader.dataset.meta_processor.meta_text_labels(
                self.dataset_config)
            outputs = self.to_ctx(outputs, ctx)
            label_hidden_states = model.forward_text(**outputs).cpu()
            label_sim = label_hidden_states @ label_hidden_states.t()
            num_labels = label_sim.size(0)
            eye_mask = ~torch.eye(num_labels, dtype=torch.bool)
            label_sim = label_sim.masked_select(eye_mask).view(num_labels, num_labels - 1)
            lbd = label_sim.max()

        # this is not a loss but just compute neg_log_prob.
        Y_pred = []
        Y_true = []
        with torch.no_grad():
            for batch in eval_dataloader:
                self(batch, label_hidden_states, model, lbd, Y_pred, Y_true)
        return self.finalize(Y_pred, Y_true, output_file)
refactored from line 144:
        https://github.com/DmZhukov/CrossTask/blob/master/train.py
        
understand_icl/fairseq/examples/MMPT/mmpt/evaluators/predictor.py