code: def verify_salt_and_pepper(
      output,
      input,
      prob,
      salt_vs_pepper,
      per_channel,
      salt_val,
      pepper_val,
  ):
      assert output.shape == input.shape
      height, width, nchannels = output.shape
      npixels = height * width
      salt_count = 0
      pepper_count = 0
      pixel_count = 0
      if per_channel:
          output = np.reshape(output, (npixels * nchannels, 1))
          input = np.reshape(input, (npixels * nchannels, 1))
      passthrough_mask = np.all(output == input, axis=-1)
      pepper_mask = np.all(output == pepper_val, axis=-1)
      salt_mask = np.all(output == salt_val, axis=-1)
      # This mask is meant to select only the pixels that didn't have a 'salt' or 'pepper'
      # value before the noise application. Otherwise, the measured noise/pepper percentages,
      # might differ a lot in images with a lot of black or white pixels.
      in_pixel_mask = np.logical_and(
          np.all(input != pepper_val, axis=-1),
          np.all(input != salt_val, axis=-1),
      )
      salt_count = np.count_nonzero(
          np.logical_and(salt_mask, in_pixel_mask)
      )
      pepper_count = np.count_nonzero(
          np.logical_and(pepper_mask, in_pixel_mask)
      )
      pixel_count = np.count_nonzero(in_pixel_mask)
      assert (
          np.logical_or(
              passthrough_mask, np.logical_or(salt_mask, pepper_mask)
          )
      ).all()
      actual_noise_prob = (pepper_count + salt_count) / pixel_count
      actual_salt_vs_pepper = salt_count / (salt_count + pepper_count)
      np.testing.assert_allclose(actual_noise_prob, prob, atol=1e-2)
      np.testing.assert_allclose(
          actual_salt_vs_pepper, salt_vs_pepper, atol=1e-1
      )
  
file_path: DALI/dali/test/python/operator_1/test_noise_salt_and_pepper.py
imports: from nvidia.dali import pipeline_def
  import nvidia.dali.fn
  import nvidia.dali.types
  import random
  import numpy
  import os
  from test_utils import get_dali_extra_path
  from test_noise_utils import PSNR
label_desc: Use image node_id 3 for calling a global function with example usage: verify_salt_and_pepper(output, input, prob, salt_vs_pepper, per_channel, salt_val, pepper_val) without return types