import torch


def model_predict(model, test_loader, device):
    """
    Predict data in dataloader using model
    """
    # Set model to eval mode
    model.eval()

    # Predict without computing gradients
    with torch.no_grad():
        y_preds = []
        y_true = []
        for inputs, labels in test_loader:
            inputs = inputs.to(device)
            labels = labels.to(device)
            outputs = model(inputs)
            _, preds = torch.max(outputs, 1)

            y_preds.append(preds)
            y_true.append(labels)

    y_preds = torch.cat(y_preds).tolist()
    y_true = torch.cat(y_true).tolist()

    return y_preds, y_true