code: def _test_preprocessing_defences_forward(
      get_default_mnist_subset,
      image_dl_estimator,
      device_type,
      preprocessing_defences,
  ):
      (_, _), (x_test_mnist, y_test_mnist) = get_default_mnist_subset
  
      classifier_, _ = image_dl_estimator()
  
      clip_values = (0, 1)
      criterion = nn.CrossEntropyLoss()
      classifier = PyTorchClassifier(
          clip_values=clip_values,
          model=classifier_.model,
          preprocessing_defences=preprocessing_defences,
          loss=criterion,
          input_shape=(1, 28, 28),
          nb_classes=10,
          device_type=device_type,
      )
  
      with torch.no_grad():
          predictions_classifier = classifier.predict(x_test_mnist)
  
      # Apply the same defences by hand
      x_test_defense = x_test_mnist
      for defence in preprocessing_defences:
          x_test_defense, _ = defence(x_test_defense, y_test_mnist)
  
      x_test_defense = torch.tensor(x_test_defense)
      with torch.no_grad():
          predictions_check = classifier_.model(x_test_defense)
      predictions_check = predictions_check.cpu().numpy()
  
      # Check that the prediction results match
      np.testing.assert_array_almost_equal(
          predictions_classifier, predictions_check, decimal=4
      )
  
imports: import numpy
  import pytest
  import torch
  import torch.nn.functional
  import torch.nn
  import torch.optim
  import sklearn.datasets
  from art.estimators.classification.pytorch import PyTorchClassifier
  from art.defences.preprocessor.spatial_smoothing import SpatialSmoothing
  from art.defences.preprocessor.spatial_smoothing_pytorch import SpatialSmoothingPyTorch
  from art.attacks.evasion.fast_gradient import FastGradientMethod
  from art.attacks.evasion.projected_gradient_descent.projected_gradient_descent import ProjectedGradientDescent
  from tests.attacks.utils import backend_test_defended_images
  from tests.utils import ARTTestException
label_desc: Use image node_id 2 for calling a global function with example usage: _test_preprocessing_defences_forward(get_default_mnist_subset, image_dl_estimator, device_type, preprocessing_defences) without return types