code: def test_get_activation_sequential(
      get_default_mnist_subset, image_dl_estimator, device_type
  ):
      (_, _), (x_test_mnist, y_test_mnist) = get_default_mnist_subset
      classifier, _ = image_dl_estimator(functional=True)
      batch_size = x_test_mnist.shape[0]
      N = len(classifier.layer_names)
      for i, name in enumerate(classifier.layer_names):
          if i == N - 1:
              activation_i = classifier.get_activations(
                  x_test_mnist, i, batch_size=batch_size
              )
              features_i = classifier.model(
                  torch.from_numpy(x_test_mnist)
              )
              features_i = features_i.detach().cpu().numpy()
  
          else:
              activation_i = classifier.get_activations(
                  x_test_mnist, i, batch_size=batch_size
              )
              features_i = (
                  nn.Sequential(
                      *list(classifier.model.children())[: i + 1]
                  )(torch.from_numpy(x_test_mnist))
                  .detach()
                  .cpu()
                  .numpy()
              )
          np.testing.assert_array_almost_equal(
              activation_i, features_i, 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 13 for calling a global function with example usage: test_get_activation_sequential(get_default_mnist_subset, image_dl_estimator, device_type) without return types