code: def salt_and_pepper_noise_ref(
      x, prob, salt_vs_pepper, per_channel, salt_val, pepper_val
  ):
      x = np.array(x, dtype=np.float32)
      salt_prob = prob * salt_vs_pepper
      pepper_prob = prob * (1.0 - salt_vs_pepper)
      nchannels = x.shape[-1]
      mask_sh = x.shape if per_channel else x.shape[:-1]
      mask = np.random.choice(
          [pepper_val, np.nan, salt_val],
          p=[pepper_prob, 1 - prob, salt_prob],
          size=mask_sh,
      )
      if not per_channel:
          mask = np.stack([mask] * nchannels, axis=-1)
      y = np.where(np.isnan(mask), x, mask).astype(np.uint8)
      return y
  
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 1 for calling a global function with example usage: salt_and_pepper_noise_ref(x, prob, salt_vs_pepper, per_channel, salt_val, pepper_val) and returns: y