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)
      loss_object = tf.keras.losses.CategoricalCrossentropy(
          from_logits=True
      )
      classifier = TensorFlowV2Classifier(
          clip_values=clip_values,
          model=classifier_.model,
          preprocessing_defences=preprocessing_defences,
          loss_object=loss_object,
          input_shape=(28, 28, 1),
          nb_classes=10,
      )
  
      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 = tf.convert_to_tensor(x_test_defense)
      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 tensorflow
  import sklearn
  import sklearn.datasets
  import sklearn.model_selection
  from art.estimators.classification.tensorflow import TensorFlowV2Classifier
  from art.estimators.classification.keras import KerasClassifier
  from art.defences.preprocessor.spatial_smoothing import SpatialSmoothing
  from art.defences.preprocessor.spatial_smoothing_tensorflow import SpatialSmoothingTensorFlowV2
  from art.attacks.evasion import FastGradientMethod, 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