code: def test_sum(self):
      # check the number of valid pixels in the neighborhood
  
      image8 = np.array(
          [
              [0, 0, 0, 0, 0],
              [0, 1, 1, 1, 0],
              [0, 1, 1, 1, 0],
              [0, 1, 1, 1, 0],
              [0, 0, 0, 0, 0],
          ],
          dtype=np.uint8,
      )
      image16 = 400 * np.array(
          [
              [0, 0, 0, 0, 0],
              [0, 1, 1, 1, 0],
              [0, 1, 1, 1, 0],
              [0, 1, 1, 1, 0],
              [0, 0, 0, 0, 0],
          ],
          dtype=np.uint16,
      )
      elem = np.ones((3, 3), dtype=np.uint8)
      out8 = np.empty_like(image8)
      out16 = np.empty_like(image16)
      mask = np.ones(image8.shape, dtype=np.uint8)
  
      r = np.array(
          [
              [1, 2, 3, 2, 1],
              [2, 4, 6, 4, 2],
              [3, 6, 9, 6, 3],
              [2, 4, 6, 4, 2],
              [1, 2, 3, 2, 1],
          ],
          dtype=np.uint8,
      )
      rank.sum(image=image8, footprint=elem, out=out8, mask=mask)
      assert_equal(r, out8)
      rank.sum_percentile(
          image=image8,
          footprint=elem,
          out=out8,
          mask=mask,
          p0=0.0,
          p1=1.0,
      )
      assert_equal(r, out8)
      rank.sum_bilateral(
          image=image8,
          footprint=elem,
          out=out8,
          mask=mask,
          s0=255,
          s1=255,
      )
      assert_equal(r, out8)
  
      r = 400 * np.array(
          [
              [1, 2, 3, 2, 1],
              [2, 4, 6, 4, 2],
              [3, 6, 9, 6, 3],
              [2, 4, 6, 4, 2],
              [1, 2, 3, 2, 1],
          ],
          dtype=np.uint16,
      )
      rank.sum(image=image16, footprint=elem, out=out16, mask=mask)
      assert_equal(r, out16)
      rank.sum_percentile(
          image=image16,
          footprint=elem,
          out=out16,
          mask=mask,
          p0=0.0,
          p1=1.0,
      )
      assert_equal(r, out16)
      rank.sum_bilateral(
          image=image16,
          footprint=elem,
          out=out16,
          mask=mask,
          s0=1000,
          s1=1000,
      )
      assert_equal(r, out16)
  
imports: import numpy
  import pytest
  from skimage import data, morphology, util
  from skimage._shared._warnings import expected_warnings
  from skimage._shared.testing import assert_allclose, assert_array_almost_equal, assert_equal, fetch, run_in_parallel
  from skimage.filters import rank
  from skimage.filters.rank import __all__
  from skimage.filters.rank import subtract_mean
  from skimage.morphology import ball, disk, gray
  from skimage.util import img_as_float, img_as_ubyte
label_desc: Use image node_id 33 for calling the TestRank obj's underlying member method code with example usage: obj.test_sum() without return types