code: def SpatialSmoothingDefence(
      x, y=None, window_size=2, channel_index=0
  ):
      assert channel_index < len(x.shape)
  
      # 在每个信道都进行中值滤波 窗口大小为window_size 彩色信道为1
      median_filte_size = [1] + [window_size] * (len(x.shape) - 1)
      median_filte_size[channel_index] = 1
      median_filte_size = tuple(median_filte_size)
  
      res = ndimage.filters.median_filter(
          x, size=median_filte_size, mode="reflect"
      )
  
      return res
  
imports: import logging
  import numpy
  from scipy import ndimage
label_desc: Use image node_id 1 for calling a global function with example usage: SpatialSmoothingDefence(x, y, window_size, channel_index) and returns: res