code: def test_bpda_on_activations(device, func):
      data = vecdata.detach().clone()
      data = data - data.mean()
  
      grad_from_self = _calc_datagrad_on_defense(func, data)
  
      func_with_idenity_backward = BPDAWrapper(
          func, forwardsub=_identity
      )
      grad_from_identity_backward = _calc_datagrad_on_defense(
          func_with_idenity_backward, data
      )
  
      func_with_self_backward = BPDAWrapper(func, forwardsub=func)
      grad_from_self_backward = _calc_datagrad_on_defense(
          func_with_self_backward, data
      )
  
      assert not torch_allclose(
          grad_from_identity_backward, grad_from_self
      )
      assert torch_allclose(grad_from_self_backward, grad_from_self)
  
file_path: advertorch/tests/test_bpda.py
imports: import itertools
  import pytest
  import torch
  import torch.nn
  from advertorch.bpda import BPDAWrapper
  from advertorch.utils import torch_allclose
  from advertorch.test_utils import withgrad_defenses
  from advertorch.test_utils import nograd_defenses
  from advertorch.test_utils import defense_kwargs
  from advertorch.test_utils import defense_data
  from advertorch.test_utils import vecdata
label_desc: Use image node_id 6 for calling a global function with example usage: test_bpda_on_activations(device, func) without return types