code: def test_median_filter():
      # XXX: doesn't pass when kernel_size is even
      # XXX: when kernel_size is odd, pixels on the boundaries are different
      kernel_size = 3
      padding = kernel_size // 2
      rval_scipy = ndimage.filters.median_filter(
          data.detach().numpy(), size=(1, 1, kernel_size, kernel_size)
      )
      rval = (
          MedianSmoothing2D(kernel_size=kernel_size)(data)
          .detach()
          .numpy()
      )
      assert np.allclose(
          rval_scipy[:, :, padding:-padding, padding:-padding],
          rval[:, :, padding:-padding, padding:-padding],
      )
  
file_path: advertorch/tests/test_defenses_correct.py
imports: import numpy
  from scipy import ndimage
  from advertorch.test_utils import generate_data_model_on_img
  from advertorch.utils import torch_allclose
  from advertorch.defenses import BinaryFilter
  from advertorch.defenses import MedianSmoothing2D
label_desc: Use image node_id 2 for calling a global function with example usage: test_median_filter() without return types