code: def _testimpl_operator_noise_salt_and_pepper(
      device,
      per_channel,
      prob,
      salt_vs_pepper,
      channel_first,
      salt_val,
      pepper_val,
      batch_size,
      niter,
  ):
      pipe = pipe_salt_and_pepper_noise(
          prob,
          salt_vs_pepper,
          channel_first,
          per_channel,
          salt_val,
          pepper_val,
          device=device,
          batch_size=batch_size,
          num_threads=3,
          device_id=0,
          seed=12345,
      )
      pipe.build()
      salt_val = 255 if salt_val is None else salt_val
      pepper_val = 0 if pepper_val is None else pepper_val
      for _ in range(niter):
          out_data, in_data, prob_arg, salt_vs_pepper_arg = pipe.run()
          prob_arg = prob_arg.as_array()
          salt_vs_pepper_arg = salt_vs_pepper_arg.as_array()
          if device == "gpu":
              out_data = out_data.as_cpu()
              in_data = in_data.as_cpu()
          for s in range(batch_size):
              sample_in = np.array(out_data[s])
              sample_out = np.array(in_data[s])
              if (
                  channel_first
              ):  # Convert back to channel-last before verifying
                  sample_out = np.transpose(sample_out, axes=(1, 2, 0))
                  sample_in = np.transpose(sample_in, axes=(1, 2, 0))
              prob = float(prob_arg[s])
              salt_vs_pepper = float(salt_vs_pepper_arg[s])
              sample_ref = salt_and_pepper_noise_ref(
                  sample_in,
                  prob,
                  salt_vs_pepper,
                  per_channel,
                  salt_val,
                  pepper_val,
              )
              psnr_out = PSNR(sample_out, sample_in)
              psnr_ref = PSNR(sample_ref, sample_in)
              if dump_images:
                  import cv2
  
                  suffix_str = f"{prob}_{salt_vs_pepper}_s{s}"
                  if not per_channel:
                      suffix_str = suffix_str + "_monochrome"
                  cv2.imwrite(
                      f"./snp_noise_ref_p{suffix_str}.png",
                      cv2.cvtColor(sample_ref, cv2.COLOR_BGR2RGB),
                  )
                  cv2.imwrite(
                      f"./snp_noise_out_p{suffix_str}.png",
                      cv2.cvtColor(sample_out, cv2.COLOR_BGR2RGB),
                  )
              verify_salt_and_pepper(
                  sample_out,
                  sample_in,
                  prob,
                  salt_vs_pepper,
                  per_channel,
                  salt_val,
                  pepper_val,
              )
              np.testing.assert_allclose(psnr_out, psnr_ref, atol=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 4 for calling a global function with example usage: _testimpl_operator_noise_salt_and_pepper(device, per_channel, prob, salt_vs_pepper, channel_first, salt_val, pepper_val, batch_size, niter) without return types