code: def test_cifar_certified_training(art_warning, fix_get_cifar10_data):
      """
      Check the following properties for the first 10 samples of the CIFAR 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
      """
  
      bound = 0.01
  
      ptc = get_cifar10_image_classifier_pt(from_logits=True)
  
      import torch.optim as optim
  
      optimizer = optim.Adam(ptc.model.parameters(), lr=1e-4)
      zonotope_model = PytorchDeepZ(
          model=ptc.model,
          optimizer=optimizer,
          clip_values=(0, 1),
          loss=torch.nn.CrossEntropyLoss(),
          input_shape=(3, 32, 32),
          nb_classes=10,
      )
  
      pgd_params = {
          "eps": 8 / 255,
          "eps_step": 1 / 255,
          "max_iter": 20,
          "num_random_init": 0,
          "batch_size": 64,
      }
  
      trainer = AdversarialTrainerCertifiedPytorch(
          zonotope_model,
          pgd_params=pgd_params,
          batch_size=10,
          bound=bound,
      )
  
      np.random.seed(123)
      random.seed(123)
      device = torch.device(
          "cuda:0" if torch.cuda.is_available() else "cpu"
      )
  
      try:
          trainer._classifier.model.set_forward_mode("concrete")
          prediction = trainer._classifier.model.forward(
              fix_get_cifar10_data[0]
          )
          loss = trainer._classifier.concrete_loss(
              prediction,
              torch.tensor(fix_get_cifar10_data[1]).to(device),
          )
          assert round(float(loss.cpu().detach().numpy()), 4) == 1.0611
  
          trainer.fit(
              fix_get_cifar10_data[0],
              fix_get_cifar10_data[1],
              nb_epochs=3,
          )
          prediction = trainer._classifier.model.forward(
              fix_get_cifar10_data[0]
          )
  
          loss = trainer._classifier.concrete_loss(
              prediction,
              torch.tensor(fix_get_cifar10_data[1]).to(device),
          )
          assert round(float(loss.cpu().detach().numpy()), 4) == 1.0092
      except ARTTestException as e:
          art_warning(e)
  
file_path: adversarial-robustness-toolbox/tests/defences/trainer/test_certified_adversarial_trainer.py
imports: import pytest
  import numpy
  import random
  import torch
  from art.utils import load_dataset
  from art.estimators.certification.deep_z import PytorchDeepZ
  from art.attacks.evasion.projected_gradient_descent.projected_gradient_descent import ProjectedGradientDescent
  from art.defences.trainer import AdversarialTrainerCertifiedPytorch
  from tests.utils import ARTTestException
  from tests.utils import get_image_classifier_pt, get_cifar10_image_classifier_pt
label_desc: Use image node_id 5 for calling a global function with example usage: test_cifar_certified_training(art_warning, fix_get_cifar10_data) without return types