def test_mnist_certified_training(art_warning, fix_get_mnist_data):
    """
    Check the following properties for the first 100 samples of the MNIST test set given an l_inft bound
        1) Check regular loss
        2) Train the model for 3 epochs using certified training.
        3) Re-Check regular loss
    """
    device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")

    ptc = get_image_classifier_pt(from_logits=True, use_maxpool=False)
    import torch.optim as optim

    optimizer = optim.Adam(ptc.model.parameters(), lr=1e-4)
    zonotope_model = PytorchDeepZ(
        model=ptc.model.to(device),
        optimizer=optimizer,
        clip_values=(0, 1),
        loss=torch.nn.CrossEntropyLoss(),
        input_shape=(1, 28, 28),
        nb_classes=10,
    )

    pgd_params = {"eps": 0.25, "eps_step": 0.05, "max_iter": 20, "num_random_init": 0, "batch_size": 64}

    trainer = AdversarialTrainerCertifiedPytorch(zonotope_model, pgd_params=pgd_params, batch_size=10, bound=0.1)

    np.random.seed(123)
    random.seed(123)
    torch.manual_seed(123)
    try:
        # Check losses pre-training
        trainer._classifier.model.set_forward_mode("concrete")
        prediction = trainer._classifier.model.forward(fix_get_mnist_data[0])
        loss = trainer._classifier.concrete_loss(prediction, torch.tensor(fix_get_mnist_data[1]).to(device))
        assert round(float(loss.cpu().detach().numpy()), 3) == 0.095

        trainer.fit(fix_get_mnist_data[0], fix_get_mnist_data[1], nb_epochs=3)

        # Check losses post-training
        prediction = trainer._classifier.model.forward(fix_get_mnist_data[0])
        loss = trainer._classifier.concrete_loss(prediction, torch.tensor(fix_get_mnist_data[1]).to(device))
        assert round(float(loss.cpu().detach().numpy()), 3) == 0.092

    except ARTTestException as e:
        art_warning(e)

    Check the following properties for the first 100 samples of the MNIST test set given an l_inft bound
        1) Check regular loss
        2) Train the model for 3 epochs using certified training.
        3) Re-Check regular loss
    
tests/defences/trainer/test_certified_adversarial_trainer.py