def _prediction_loop(self, dataset: tf.data.Dataset, description: str, prediction_loss_only: Optional[bool]=None) -> PredictionOutput:
    logger.info('***** Running %s *****', description)
    logger.info('  Batch size = %d', self.args.eval_batch_size)
    label_ids: np.ndarray = None
    preds: np.ndarray = None
    step: int = 1
    for (features, labels) in dataset:
        step = tf.convert_to_tensor(step, dtype=tf.int64)
        (loss, logits) = self._evaluate_steps(features, labels)
        loss = tf.reduce_mean(loss)
        if (not prediction_loss_only):
            if (self.args.n_gpu > 1):
                for val in logits.values:
                    if (preds is None):
                        preds = val.numpy()
                    else:
                        preds = np.append(preds, val.numpy(), axis=0)
                for val in labels.values:
                    if (label_ids is None):
                        label_ids = val.numpy()
                    else:
                        label_ids = np.append(label_ids, val.numpy(), axis=0)
            else:
                if (preds is None):
                    preds = logits.numpy()
                else:
                    preds = np.append(preds, logits.numpy(), axis=0)
                if (label_ids is None):
                    label_ids = labels.numpy()
                else:
                    label_ids = np.append(label_ids, labels.numpy(), axis=0)
        step += 1
    if ((self.compute_metrics is not None) and (preds is not None) and (label_ids is not None)):
        metrics = self.compute_metrics(EvalPrediction(predictions=preds, label_ids=label_ids))
    else:
        metrics = {}
    metrics['eval_loss'] = loss.numpy()
    for key in list(metrics.keys()):
        if (not key.startswith('eval_')):
            metrics[f'eval_{key}'] = metrics.pop(key)
    return PredictionOutput(predictions=preds, label_ids=label_ids, metrics=metrics)
def _prediction_loop(self, dataset: tf.data.Dataset, description: str, prediction_loss_only: Optional[bool]=None) -> PredictionOutput:
    logger.info('***** Running %s *****', description)
    logger.info('  Batch size = %d', self.args.eval_batch_size)
    label_ids: np.ndarray = None
    preds: np.ndarray = None
    step: int = 1
    for (features, labels) in dataset:
        step = tf.convert_to_tensor(step, dtype=tf.int64)
        (loss, logits) = self._evaluate_steps(features, labels)
        loss = tf.reduce_mean(loss)
        if (not prediction_loss_only):
            if (self.args.n_gpu > 1):
                for val in logits.values:
                    if (preds is None):
                        preds = val.numpy()
                    else:
                        preds = np.append(preds, val.numpy(), axis=0)
                for val in labels.values:
                    if (label_ids is None):
                        label_ids = val.numpy()
                    else:
                        label_ids = np.append(label_ids, val.numpy(), axis=0)
            else:
                if (preds is None):
                    preds = logits.numpy()
                else:
                    preds = np.append(preds, logits.numpy(), axis=0)
                if (label_ids is None):
                    label_ids = labels.numpy()
                else:
                    label_ids = np.append(label_ids, labels.numpy(), axis=0)
        step += 1
    if ((self.compute_metrics is not None) and (preds is not None) and (label_ids is not None)):
        metrics = self.compute_metrics(EvalPrediction(predictions=preds, label_ids=label_ids))
    else:
        metrics = {}
    metrics['eval_loss'] = loss.numpy()
    for key in list(metrics.keys()):
        if (not key.startswith('eval_')):
            metrics[f'eval_{key}'] = metrics.pop(key)
    return PredictionOutput(predictions=preds, label_ids=label_ids, metrics=metrics)